Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QueryPerformanceCounter in D?

Tags:

d

Is there something (planned) in the D Library to support high precision timers like QueryPerformanceCounter in c++ ? How can I have a portable High precision timer in D ?

Or if it is not available, what would be the highest percision timer in D ?

like image 736
Roel Van Nyen Avatar asked Sep 23 '11 15:09

Roel Van Nyen


1 Answers

std.datetime has the StopWatch struct for handling precision timing - and it uses QueryPerformanceCounter internally on Windows. On other OSes, it uses whatever the appropriate, high precision monotonic clock is for them.

If what you need is ticks of the system clock rather than a timer specifically, you can call Clock.currSystemTick for the current tick of the system clock (or Clock.currAppTick for the number of system clock ticks since the application started). But StopWatch is what you want if you want a timer.

like image 95
Jonathan M Davis Avatar answered Sep 21 '22 18:09

Jonathan M Davis