26 static void appendToFile (
const File& f,
const String& s)
28 if (f.getFullPathName().isNotEmpty())
30 FileOutputStream out (f);
32 if (! out.failedToOpen())
38 : runsPerPrint (runsPerPrintout), startTime (0), outputFile (loggingFile)
41 appendToFile (outputFile,
"**** Counter for \"" + name +
"\" started at: " +
Time::getCurrentTime().toString (
true,
true));
46 if (stats.numRuns > 0)
50 PerformanceCounter::Statistics::Statistics() noexcept
51 : averageSeconds(), maximumSeconds(), minimumSeconds(), totalSeconds(), numRuns()
55 void PerformanceCounter::Statistics::clear() noexcept
57 averageSeconds = maximumSeconds = minimumSeconds = totalSeconds = 0;
61 void PerformanceCounter::Statistics::addResult (
double elapsed) noexcept
65 maximumSeconds = elapsed;
66 minimumSeconds = elapsed;
70 maximumSeconds = jmax (maximumSeconds, elapsed);
71 minimumSeconds = jmin (minimumSeconds, elapsed);
75 totalSeconds += elapsed;
78 static String timeToString (
double secs)
80 return String ((int64) (secs * (secs < 0.01 ? 1000000.0 : 1000.0) + 0.5))
81 + (secs < 0.01 ?
" microsecs" :
" millisecs");
84 String PerformanceCounter::Statistics::toString()
const 88 s <<
"Performance count for \"" << name <<
"\" over " << numRuns <<
" run(s)" << newLine
89 <<
"Average = " << timeToString (averageSeconds)
90 <<
", minimum = " << timeToString (minimumSeconds)
91 <<
", maximum = " << timeToString (maximumSeconds)
92 <<
", total = " << timeToString (totalSeconds);
106 if (stats.numRuns < runsPerPrint)
118 appendToFile (outputFile, desc);
127 s.averageSeconds = s.totalSeconds / s.numRuns;
static int64 getHighResolutionTicks() noexcept
static Time JUCE_CALLTYPE getCurrentTime() noexcept
static double highResolutionTicksToSeconds(int64 ticks) noexcept
static void JUCE_CALLTYPE outputDebugString(const String &text)