StopWatch.peek

Peek at the amount of time that the the StopWatch has been running.

This does not include any time during which the StopWatch was stopped but does include all of the time that it was running and not just the time since it was started last.

Calling reset will reset this to Duration.zero.

struct StopWatch
@safe const nothrow @nogc
Duration
peek
()

Examples

import core.thread : Thread;

auto sw = StopWatch(AutoStart.no);
assert(sw.peek() == Duration.zero);
sw.start();

Thread.sleep(usecs(1));
assert(sw.peek() >= usecs(1));

Thread.sleep(usecs(1));
assert(sw.peek() >= usecs(2));

sw.stop();
immutable stopped = sw.peek();
Thread.sleep(usecs(1));
assert(sw.peek() == stopped);

sw.start();
Thread.sleep(usecs(1));
assert(sw.peek() > stopped);
Suggestion Box / Bug Report