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