UTNuclearRoboticsPublic / cpp_timer

Function timer for C++
BSD 2-Clause "Simplified" License
4 stars 0 forks source link

Comparision to other methods #4

Open onurtore opened 1 year ago

onurtore commented 1 year ago

Hi! The last time I was measuring code in cpp I was using Chrono Steady Clock. I was wondering whether approach in this repository has higher accuracy?

alexnavtt commented 1 year ago

Sorry, I missed this question. Internally, this library uses chrono steady clock, but it has some additional logic to organize the data which will lose some slight accuracy. I've taken as many steps as possible to try to minimize this effect (the actual data processing happens in a separate thread) but the more semantics you put into timing the more accuracy you lose. On my computer, a chrono call takes on the order of 50ns and a timer tic toc sequence is around 300ns. That being said, I've found this method to be extremely useful for identifying bottlenecks and optimization targets in code without a whole lot of effort