26static void appendToFile (
const File& f,
const String& s)
28 if (f.getFullPathName().isNotEmpty())
30 FileOutputStream out (f);
32 if (! out.failedToOpen())
41 appendToFile (outputFile,
"**** Counter for \"" + name +
"\" started at: " +
Time::getCurrentTime().toString (
true,
true));
46 if (stats.numRuns > 0)
50PerformanceCounter::Statistics::Statistics() noexcept
51 : averageSeconds(), maximumSeconds(), minimumSeconds(), totalSeconds(), numRuns()
55void PerformanceCounter::Statistics::clear() noexcept
57 averageSeconds = maximumSeconds = minimumSeconds = totalSeconds = 0;
61void PerformanceCounter::Statistics::addResult (
double elapsed)
noexcept
78static String timeToString (
double secs)
80 return String ((
int64) (
secs * (
secs < 0.01 ? 1000000.0 : 1000.0) + 0.5))
81 + (
secs < 0.01 ?
" microsecs" :
" millisecs");
84String 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 / (
float) s.numRuns;
Represents a local file or directory.
static void JUCE_CALLTYPE writeToLog(const String &message)
Writes a string to the current logger.
static Time JUCE_CALLTYPE getCurrentTime() noexcept
Returns a Time object that is set to the current system time.
static double highResolutionTicksToSeconds(int64 ticks) noexcept
Converts a number of high-resolution ticks into seconds.
static int64 getHighResolutionTicks() noexcept
Returns the current high-resolution counter's tick-count.
NewLine newLine
A predefined object representing a new-line, which can be written to a string or stream.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
long long int64
A platform-independent 64-bit integer type.