Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 20, 2015 StopWatch | ||||
---|---|---|---|---|
| ||||
http://dlang.org/phobos/std_datetime.html#StopWatch shows the use of TickDuration to measure the time elapsed, but http://dlang.org/phobos/core_time.html#TickDuration says TickDuration is due to be deprecated and MonoTime should be used. It is possible to measure the duration between two points of one's program using MonoTime.currTime whose unit is Duration. 1) Will then StopWatch be modified to use MonoTime? 2) Is StopWatch still useful? 3) Or should it also be deprecated? -- Shriramana Sharma, Penguin #395953 |
October 20, 2015 Re: StopWatch | ||||
---|---|---|---|---|
| ||||
Posted in reply to Shriramana Sharma | On Tuesday, October 20, 2015 13:18:12 Shriramana Sharma via Digitalmars-d-learn wrote: > http://dlang.org/phobos/std_datetime.html#StopWatch shows the use of TickDuration to measure the time elapsed, but http://dlang.org/phobos/core_time.html#TickDuration says TickDuration is due to be deprecated and MonoTime should be used. It is possible to measure the duration between two points of one's program using MonoTime.currTime whose unit is Duration. > > 1) Will then StopWatch be modified to use MonoTime? > 2) Is StopWatch still useful? > 3) Or should it also be deprecated? There's currently a PR open to replace StopWatch with another one which uses Duration and MonoTime instead of TickDuration: https://github.com/D-Programming-Language/phobos/pull/3695 So, std.datetime.StopWatch is going to be deprecated as will every function in druntime or Phobos which uses TickDuration in its public API. They'll be replaced with functions that use MonoTime and Duration. That being said, unless you need to stop measuring the time and start from where you left off, StopWatch isn't necessary. If all you want to do is measure how long something takes, MonoTime is plenty. e.g. auto before = MonoTime.currTime; // do stuff auto diff = MonoTime.currTime - before; The value of StopWatch is entirely in the fact that it can be stopped and started again and measure the total time that it's running rather than just measure the time between two points. - Jonathan M Davis |
October 20, 2015 Re: StopWatch | ||||
---|---|---|---|---|
| ||||
Attachments:
| On Tue, 2015-10-20 at 02:19 -0700, Jonathan M Davis via Digitalmars-d- learn wrote: > […] > > auto before = MonoTime.currTime; > // do stuff > auto diff = MonoTime.currTime - before; What import statement do you use to get MonoTime. I tried the above and got an error with all the things I tried. -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
October 20, 2015 Re: StopWatch | ||||
---|---|---|---|---|
| ||||
Attachments:
| On Tue, 2015-10-20 at 15:16 +0100, Russel Winder wrote: > […] > What import statement do you use to get MonoTime. I tried the above and got an error with all the things I tried. Hummm… I am now not worried about the import, I tried compiling a different way and it worked. The upshot is that I have had two installations of LDC which are mutually incompatible re core.time and the configuration leads to total wrongness. Forget I ever mumbled on this topic… :-) -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
Copyright © 1999-2021 by the D Language Foundation