Take the 2-minute tour ×

Does boost chrono provides time stamp with nanoseconds resolution?? If yes how to get the time stamp?

share|improve this question
As you insist. The best you can theoretically get since Vista is by using HPET (High Precision Event Timer). See here en.wikipedia.org/wiki/High_Precision_Event_Timer. The problem is how to get it via QueryPerformanceCounter() that uses the HPET when available and set in BIOS. –  SChepurin Oct 18 '12 at 15:15
@SChepurin "The best you can theoretically get since Vista is by using HPET"? Why if my processor works with 3.33 GHz it is because it is the fastes clock in OS? –  Narek Oct 19 '12 at 8:40
add comment

2 Answers

up vote 2 down vote accepted

Nanoseconds resolution ? On which hardware do you want to run your program ? On my PC, my performance counter has a frequency of approx. 4 Mhz, so a tick last 250 ns.

As answered here, boost chrono can give you the nanosecond resolution, but you will not be sure of the measure's accuracy.

share|improve this answer
So how to know my performance counter frequency? And is this the only criterion that indicates the precision? –  Narek Oct 18 '12 at 18:11
as stated by @SChepurin, QueryPerformanceFrequency() retrieve your HPET's frequency clock (in Hz) if you work on Windows. For Linux, there should be a equivalent function, but I do not know its name. For more info : mindcontrol.org/~hplus/pc-timers.html –  georgesl Oct 18 '12 at 19:47
I mean if you processor is 3.33GHz it is not enough to obtain time in nanoseconds? Why would we concern about HPET's frequency? –  Narek Oct 19 '12 at 8:35
you can use CPU time ( a lot of methods are posted here ) but remember that we don't know the accuracy of the CPU's clock frequency (is it 3.33Ghz or 3.00 Ghz ?) nor the CPU's optimization ( wall time, load balancer if several cores, ...). I think the result given by CPU time measurement does not have any significant figures below the microsecond. –  georgesl Oct 19 '12 at 9:08
add comment

In order to easily get time stamps with boost chrono for different measurements you can use boost CPU Timers. A table about the timer accuracy is also given on this site.

To measure the resolution yourself on your specific hardware use boost's cpu_timer_info.cpp.

share|improve this answer
add comment

Your Answer


