Better than "Clock.currStdTime()/10000000"
berni via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Feb 15 12:26:03 PST 2017
On Wednesday, 15 February 2017 at 15:58:41 UTC, Jonathan M Davis
wrote:
>> [...]
>> MonoTime before = MonoTime.currTime;
>> Thread.sleep(dur!"msecs"(1000));
>> MonoTime after = MonoTime.currTime;
>> Duration timeElapsed = after - before;
>>
>> writeln(timeElapsed);
>> }
>> ```
>> I get: "1 sec, 26 μs, and 4 hnsecs"
>
> This is the correct way to do it. [...]
Oh, thanks for noting this. As I finally needed the seconds as an
int (or long) I had to use timeElapsed.total!"seconds" which I
would not have found out without Seb's posting. :-)
More information about the Digitalmars-d-learn
mailing list