2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCE_PERFORMANCECOUNTER_JUCEHEADER__
27 #define __JUCE_PERFORMANCECOUNTER_JUCEHEADER__
29 #include "../io/files/juce_File.h"
32 //==============================================================================
33 /** A timer for measuring performance of code and dumping the results to a file.
37 PerformanceCounter pc ("fish", 50, "/temp/myfishlog.txt");
49 In this example, the time of each period between calling start/stop will be
50 measured and averaged over 50 runs, and the results printed to a file
51 every 50 times round the loop.
53 class JUCE_API PerformanceCounter
56 //==============================================================================
57 /** Creates a PerformanceCounter object.
59 @param counterName the name used when printing out the statistics
60 @param runsPerPrintout the number of start/stop iterations before calling
62 @param loggingFile a file to dump the results to - if this is File::nonexistent,
63 the results are just written to the debugger output
65 PerformanceCounter (const String
& counterName
,
66 int runsPerPrintout
= 100,
67 const File
& loggingFile
= File::nonexistent
);
70 ~PerformanceCounter();
72 //==============================================================================
79 /** Stops timing and prints out the results.
81 The number of iterations before doing a printout of the
82 results is set in the constructor.
88 /** Dumps the current metrics to the debugger output and to a file.
90 As well as using Logger::outputDebugString to print the results,
91 this will write then to the file specified in the constructor (if
94 void printStatistics();
97 //==============================================================================
99 int numRuns
, runsPerPrint
;
105 #endif // __JUCE_PERFORMANCECOUNTER_JUCEHEADER__