public void log ( Logger logger , LogLevel priority ) { if ( LoggerWrap . isEnabledFor ( logger , priority ) ) { String timerLabel ; if ( threadId != 0 ) { timerLabel = name + " (thread " + threadId + ")" ; } else if ( threadCount > 1 ) { timerLabel = name + " (over " + threadCount + " threads)" ; } else { timerLabel = name ; } if ( todoFlags == RECORD_NONE ) { LoggerWrap . log ( logger , priority , "Timer " + timerLabel + " recorded " + measurements + " run(s), no times taken" ) ; } else { String labels = "" ; String values = "" ; String separator ; if ( ( todoFlags & RECORD_CPUTIME ) != 0 && threadId != 0 ) { labels += "CPU" ; values += totalCpuTime / 1000000 ; separator = "/" ; } else { separator = "" ; } if ( ( todoFlags & RECORD_WALLTIME ) != 0 ) { labels += separator + "Wall" ; values += separator + totalWallTime / 1000000 ; } if ( ( todoFlags & RECORD_CPUTIME ) != 0 && threadId != 0 ) { labels += "/CPU avg" ; values += "/" + ( float ) ( totalCpuTime ) / measurements / 1000000 ; } if ( ( todoFlags & RECORD_WALLTIME ) != 0 ) { labels += "/Wall avg" ; values += "/" + ( float ) ( totalWallTime ) / measurements / 1000000 ; } if ( threadCount > 1 ) { if ( ( todoFlags & RECORD_CPUTIME ) != 0 && threadId != 0 ) { labels += "/CPU per thread" ; values += "/" + ( float ) ( totalCpuTime ) / threadCount / 1000000 ; } if ( ( todoFlags & RECORD_WALLTIME ) != 0 ) { labels += "/Wall per thread" ; values += "/" + ( float ) ( totalWallTime ) / threadCount / 1000000 ; } } LoggerWrap . log ( logger , priority , "Time for " + timerLabel + " for " + measurements + " run(s) " + labels + " (ms): " + values ) ; } if ( isRunning ) { logger . warn ( "Timer " + timerLabel + " logged while it was still running" ) ; } } }
Print logging information for the timer . The log only shows the recorded time of the completed start - stop cycles . If the timer is still running then it will not be stopped to add the currently measured time to the output but a warning will be logged .