Package test.util

Examples of test.util.DataSetWriter


    }
   
    public double evalWrite(DataSet<byte[]> store, int runDuration) throws Exception {
        try {
            // Start writer
            DataSetWriter writer = new DataSetWriter(store, _lineSeedData, _keyCount);
            Thread writerThread = new Thread(writer);
            writerThread.start();
            StatsLog.logger.info("Writer started");
           
            long startTime = System.currentTimeMillis();
            long writeCount = 0;
            int heartBeats = runDuration/10;
            long sleepTime = Math.min(runDuration * 1000, 10000);
            for (int i = 0; i < heartBeats; i++) {
                Thread.sleep(sleepTime);
                long newWriteCount = writer.getOpCount();
                StatsLog.logger.info("writeCount=" + (newWriteCount - writeCount));
                writeCount = newWriteCount;
            }
           
            writer.stop();
            writerThread.join();
           
            long endTime = System.currentTimeMillis();
           
            long elapsedTime = endTime - startTime;
            StatsLog.logger.info("elapsedTime="+ elapsedTime +" ms");
           
            double rate = writer.getOpCount()/(double)elapsedTime;
            rate = Math.round(rate * 100) / 100.0;
            StatsLog.logger.info("writeCount="+ writer.getOpCount() +" rate="+ rate +" per ms");
           
            return rate;
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
View Full Code Here


                threads[i].start();
                StatsLog.logger.info("Reader " + i + " started");
            }
           
            // Start writer
            DataSetWriter writer = new DataSetWriter(store, _lineSeedData, _keyCount);
            Thread writerThread = new Thread(writer);
            writerThread.start();
            StatsLog.logger.info("Writer started");
           
            long startTime = System.currentTimeMillis();
           
            long readCount = 0;
            long writeCount = 0;
            int heartBeats = runDuration/10;
            long sleepTime = Math.min(runDuration * 1000, 10000);
            for (int i = 0; i < heartBeats; i++) {
                Thread.sleep(sleepTime);

                long newReadCount = 0;
                for (int r = 0; r < readers.length; r++) {
                    newReadCount += readers[r].getOpCount();
                }
               
                long newWriteCount = writer.getOpCount();
               
                StatsLog.logger.info("write="+ (newWriteCount-writeCount) +" read=" + (newReadCount-readCount));
               
                readCount = newReadCount;
                writeCount = newWriteCount;
            }
           
            // Stop reader
            for (int i = 0; i < readers.length; i++) {
                readers[i].stop();
            }
            for (int i = 0; i < threads.length; i++) {
                threads[i].join();
            }
           
            // Stop writer
            writer.stop();
            writerThread.join();
           
            long endTime = System.currentTimeMillis();

            long elapsedTime = endTime - startTime;
            StatsLog.logger.info("elapsedTime="+ elapsedTime +" ms");
           
            double rate = writer.getOpCount()/(double)elapsedTime;
            rate = Math.round(rate * 100) / 100.0;
            StatsLog.logger.info("writeCount="+ writer.getOpCount() +" rate="+ rate +" per ms");
           
            double sumReadRate = 0;
            for (int i = 0; i < readers.length; i++) {
                rate = readers[i].getOpCount()/(double)elapsedTime;
                rate = Math.round(rate * 100) / 100.0;
                StatsLog.logger.info("readCount["+ i +"]="+ readers[i].getOpCount() +" rate="+ rate +" per ms");
                sumReadRate += rate;
            }
           
            sumReadRate = Math.round(sumReadRate * 100) / 100.0;
            StatsLog.logger.info("Total Read Rate="+ sumReadRate +" per ms");
           
            StatsLog.logger.info("writer latency stats:");
            writer.getLatencyStats().print(StatsLog.logger);
           
            if (!doValidation) {
                StatsLog.logger.info("reader latency stats:");
                readers[0].getLatencyStats().print(StatsLog.logger);
            }
View Full Code Here

TOP

Related Classes of test.util.DataSetWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.