
If you are on an x86 platform, you can use the "rdtsc" assembly instruction to obtain processor tick counts. When I needed accurate timing, I created a function to wrap around "rdtsc", a Timer class with an API something like class Timer { public: void start(); void stop(); ulonglong elapsed(); }; Then created class using the Guard idiom around that: class AutoTimer { public: AutoTimer(Timer& t) : t_(t) { t_.start(); } ~AutoTimer() { t_.stop(); } private: Timer& t_; }; Becomes very easy to time segments of code: ... Timer t1; ... { AutoTimer a(t1); ...do stuff... } One can also continue to start/stop a Timer, thus accumulating total tick counts. Conversion of tick counts back to real time is done external to any of these classes.