Skip to content

Standard C++ High Resolution Timer with lap functionality. Accurate to within nanoseconds (system dependent). Will print function names and line numbers for laps.

License

Notifications You must be signed in to change notification settings

bwedding/HRTimer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HRTimer

Standard C++ High Resolution Timer with lap functionality. Accurate to within nanoseconds (system dependent). The print routines automatically scale the result to nanoseconds, microseconds, milliseconds, seconds or minutes, depending on the size of the value.

The Lap method will save line numbers and print them out when the print method is called. e.g.

HRTimer::HiResTimer tmr;
// Start timer
tmr.Start();
// Time execution of puts()
puts("Hello World");
// Print result as nano, micro or milli 
tmr.PrintElapsedTime();
// Reset timer
tmr.Reset();
// Save a lap
tmr.Lap();
tmr.HRSleep(1);
// Save a lap
tmr.Lap();
tmr.HRSleep(10);
// Print result of all laps as nano, micro, milli, etc
tmr.PrintLapTimes();

Outputs:

main Elapsed time: 400 NanoSeconds

main Line: 21 - Lap time: 300 NanoSeconds

main Line: 24 - Lap time: 1247 MicroSeconds

About

Standard C++ High Resolution Timer with lap functionality. Accurate to within nanoseconds (system dependent). Will print function names and line numbers for laps.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages