Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
Profiler Class ReferenceManages a hierarchy of timers for profiling time spent in code, gives microsecond resolution. More...
Detailed DescriptionManages a hierarchy of timers for profiling time spent in code, gives microsecond resolution. Doesn't use any pointers so it's safe to put this in shared memory regions. Example usage:
ProfilerOfSize<2> prof; //A global manager for all the sections void f() { static unsigned int id=prof.getNewID("f"); // <== Get the ID number Profiler::Timer timer(id,&prof.prof); // <== start the timer //... if(rand()>RAND_MAX/2) return; // destruction of timer occurs automatically! //... } // if we didn't hit the return, timer will otherwise destruct here! However, there's a macro that makes this a one liner: void g() { PROFSECTION("g",prof); // <== Most of the time, this is all you need //... // (unless you're doing something fancy like conditional timers) f(); // will note f's time as g's child time, as well as g's own time //... } The idea is similar to that used by MMAccessor. If you want to profile a section at smaller resolution than a function, you can use tricks shown in MMAccessor's documentation to limit the timer's scope. For convenience, there are three global profilers predefined: mainProfiler, motionProfiler, and soundProfiler. These are what are polled by the ProfilerCheckControl -- if you instantiate a new profiler, you will have to call its report() function yourself to get the results. (If it's simply a matter of running out of sections in mainProfiler, increase the template parameter at the end of Profiler.h) Keep in mind however, that these global profilers are pointers, and need to be dereferenced to use with the macro, e.g. Here were the constraints I set for myself:
Consessions made:
Global readability is first priority since generating reports is the primary usage, thus we have to be able to handle being in shared memory space. This means no virtual functions and no pointer storage. Unfortunately, this makes the second constraint rather difficult.
Definition at line 95 of file Profiler.h.
Constructor & Destructor Documentation
constructor, but you don't want to construct one of these! Use ProfilerOfSize<x> instead! Definition at line 119 of file Profiler.cc. Member Function Documentation
called automatically by ~Timer() - notes the specified timer as finished (doesn't check if the timer is actually the current one - don't screw up!) Definition at line 156 of file Profiler.cc. Referenced by Profiler::Timer::~Timer().
returns which bucket a time should go in, does a binary search over buckets (unless someone things a log() call would be faster...) Definition at line 182 of file Profiler.h. Referenced by finished(), and setCurrent().
returns the bucket boundaries Definition at line 156 of file Profiler.h.
gets the actual storage area of the SectionInfo's Definition at line 171 of file Profiler.h. Referenced by finished(), getNewID(), report(), reset(), and setCurrent().
call this to get a new ID number Definition at line 62 of file Profiler.cc. Referenced by ProfilerOfSize< MaxSections >::getNewID().
called during process init (before any profiled sections) Definition at line 56 of file Profiler.cc. Referenced by Profiler::AutoInit::AutoInit().
outputs profiling information Definition at line 75 of file Profiler.cc. Referenced by ProfilerOfSize< MaxSections >::report().
resets profiling information Definition at line 112 of file Profiler.cc.
called automatically by Timer() - sets the current timer Definition at line 135 of file Profiler.cc. Referenced by Profiler::Timer::setID(), and Profiler::Timer::Timer(). Friends And Related Function Documentation
Only the Timer's should be calling setCurrent() and finished() upon the Timer's construction and destruction. Definition at line 175 of file Profiler.h. Member Data Documentation
Automatically causes initialization of the histogram buckets when the first Profiler is instantiated.
holds boundaries for each bucket Definition at line 197 of file Profiler.h. Referenced by getBucket(), getBuckets(), initBuckets(), and report().
the current timer Definition at line 164 of file Profiler.h. Referenced by finished(), and setCurrent(). gamma to use with exponential averages (1 to freeze, 0 to set to last) Definition at line 166 of file Profiler.h. Referenced by finished(), and setCurrent().
affects how linearly the buckets are distributed - 1 means linear, >1 causes higher resolution for short times Definition at line 107 of file Profiler.h. Referenced by initBuckets().
number of slots in the histograms Definition at line 103 of file Profiler.h. Referenced by finished(), getBucket(), initBuckets(), report(), Profiler::SectionInfo::reset(), Profiler::SectionInfo::SectionInfo(), and setCurrent().
the upper bound (exclusive) of the histograms, in milliseconds. Definition at line 105 of file Profiler.h. Referenced by finished(), initBuckets(), and setCurrent().
NASTY HACK - this is how we get around using virtual functions. Definition at line 199 of file Profiler.h. Referenced by getInfos().
maximum length of names of timers Definition at line 101 of file Profiler.h. Referenced by getNewID().
so we can read the size of the infos array back again at runtime Definition at line 167 of file Profiler.h. Referenced by getNewID().
the number of timer IDs which have been assigned Definition at line 168 of file Profiler.h. Referenced by getNewID(), report(), and reset().
time of beginning profiling Definition at line 165 of file Profiler.h. The documentation for this class was generated from the following files: |
Tekkotsu v5.1CVS |
Generated Mon May 9 04:59:14 2016 by Doxygen 1.6.3 |