public synchronized void printStatistics() {
        // quickly memoize and update counters, get the time, record update time, etc...
        long nowSuccesses = incrementCount.get();
        long nowFailures = failureCount.get();
        long prevSuccesss = lastPeriod.getAndSet(nowSuccesses);
        long endTime = System.currentTimeMillis();
        long startTime = lastStatsReportTS;
        lastStatsReportTS = endTime;

        // do math with as much safety as possible
        long invocationsCompleted = Math.max(nowSuccesses - prevSuccesss, 0);
        long periodDurationMs = Math.max(endTime - startTime, 1);
        long cumulativeDurationMs = Math.max(endTime - benchmarkStartTS, 1);
        long periodThroughput = (long) (invocationsCompleted / (periodDurationMs / 1000.0));
        long cumulativeThroughput = (long) (nowSuccesses / (cumulativeDurationMs / 1000.0));
        long time = (long) (Math.round(endTime - benchmarkStartTS) / 1000.0);

        // print out periodic report
        System.out.printf("%02d:%02d:%02d ", time / 3600, (time / 60) % 60, time % 60);
        System.out.printf("Period Throughput %10d/s, ", periodThroughput);
        System.out.printf("Cumulative Throughput %10d/s, ", cumulativeThroughput);
        System.out.printf("Total Failures %10d", nowFailures);
        System.out.printf("\n");
    }
public synchronized void printStatistics ( ) { long nowSuccesses = incrementCount . get ( ) ; long nowFailures = failureCount . get ( ) ; long prevSuccesss = lastPeriod . getAndSet ( nowSuccesses ) ; long endTime = System . currentTimeMillis ( ) ; long startTime = lastStatsReportTS ; lastStatsReportTS = endTime ; long invocationsCompleted = Math . max ( nowSuccesses - prevSuccesss , 0 ) ; long periodDurationMs = Math . max ( endTime - startTime , 1 ) ; long cumulativeDurationMs = Math . max ( endTime - benchmarkStartTS , 1 ) ; long periodThroughput = ( long ) ( invocationsCompleted / ( periodDurationMs / 1000.0 ) ) ; long cumulativeThroughput = ( long ) ( nowSuccesses / ( cumulativeDurationMs / 1000.0 ) ) ; long time = ( long ) ( Math . round ( endTime - benchmarkStartTS ) / 1000.0 ) ; System . out . printf ( "%02d:%02d:%02d " , time / 3600 , ( time / 60 ) % 60 , time % 60 ) ; System . out . printf ( "Period Throughput %10d/s, " , periodThroughput ) ; System . out . printf ( "Cumulative Throughput %10d/s, " , cumulativeThroughput ) ; System . out . printf ( "Total Failures %10d" , nowFailures ) ; System . out . printf ( "\n" ) ; }
Print stats for the last displayinterval seconds to the console.