Public Member Functions
|Useful for creating multiple Profiler instances. |
|void||init (double smoothing=0.0, const std::string outputFilename="", size_t printPeriod=1, TimeFormat printFormat=MILLISECONDS)|
|Initializes the profiler. |
|void||beginBlock (const std::string &name)|
|Begins timing the named block of code. |
|void||endBlock (const std::string &name)|
|Defines the end of the named timing block. |
|Defines the end of a profiling cycle. |
|double||getAvgDuration (const std::string &name, TimeFormat format) const|
|Returns the average time used in the named block per profiling cycle. |
|double||getTotalDuration (const std::string &name, TimeFormat format)|
|Returns the total time spent in the named block since the profiler was initialized. |
|double||getTimeSinceInit (TimeFormat format)|
|Computes the elapsed time since the profiler was initialized. |
|std::string||getSummary (TimeFormat format=PERCENT)|
|Returns a summary of total times in each block. |
Static Public Member Functions
|static Profiler &||instance ()|
|Accesses the singleton instance. |
Useful for creating multiple Profiler instances.
Normally the Profiler class should be accessed only through the singleton instance method, which provides global access to a single static Profiler instance. However, it is also possible to create several local Profiler instances, if necessary.
|Profiler & quickprof::Profiler::instance||(||)||
|void quickprof::Profiler::init||(||double|| smoothing =
|const std::string|| outputFilename =
|size_t|| printPeriod =
|TimeFormat|| printFormat = |
Initializes the profiler.
This must be called first. If this is never called, the profiler is effectively disabled, and all other functions will return immediately. This can be called more than once to re-initialize the profiler, which erases all previous profiling block names and their timing data.
|smoothing||The measured duration for each profile block can be averaged across multiple cycles, and this parameter defines the smoothness of this averaging process. The higher the value, the smoother the resulting average durations will appear. Leaving it at zero will essentially disable the smoothing effect. More specifically, this parameter is a time constant (defined in terms of cycles) that defines an exponentially-weighted moving average. For example, a value of 4.0 means the past four cycles will contribute 63% of the current weighted average. This value must be >= 0.|
|outputFilename||If defined, enables timing data to be printed to a data file for later analysis.|
|printPeriod||Defines how often data is printed to the file, in number of profiling cycles. For example, set this to 1 if you want data printed after each cycle, or 5 if you want it printed every 5 cycles. It is a good idea to increase this if you don't want huge data files. Keep in mind, however, that when you increase this, you might want to increase the smoothing parameter. (A good heuristic is to set the smoothing parameter equal to the print period.) This value must be >= 1.|
|printFormat||Defines the format used when printing data to a file.|
|void quickprof::Profiler::beginBlock||(||const std::string &||name||)||
|void quickprof::Profiler::endBlock||(||const std::string &||name||)||
Defines the end of a profiling cycle.
Use this regularly by calling it at the end of all timing blocks. This is necessary for smoothing and for file output, but not if you just want a total summary at the end of execution (i.e. from getSummary). This must not be called within a timing block.
|double quickprof::Profiler::getAvgDuration||(||const std::string &||name,|
Returns the average time used in the named block per profiling cycle.
If smoothing is disabled (see init), this returns the most recent duration measurement.
|name||The name of the block.|
|format||The desired time format to use for the result.|
|double quickprof::Profiler::getTotalDuration||(||const std::string &||name,|
|std::string quickprof::Profiler::getSummary||(||TimeFormat|| format =