Better than "Clock.currStdTime()/10000000"

berni via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 15 05:19:57 PST 2017


I need to measure time elapsed in seconds, like this:

> auto start = Clock.currStdTime();
> // some stuff
> auto stop = Clock.currStdTime();
> auto duration = (stop-start)/10000000;

This works, but I wonder if there is something better that using 
the magic constant 10000000. I read about 10.secs giving the 
duration of 10 seconds, but I don't understand how to adapt this 
to my case. I've read the documentation of core.time, 
std.datetime (and the Introduction to this package) but I can't 
make head or tail of it.

PS: It's not about benchmarking. I'd like to show the user the 
time elapsed.


More information about the Digitalmars-d-learn mailing list