tango.time.StopWatch

License:
BSD style:

Version:
Feb 2007: Initial release

author:
Kris

struct StopWatch;
Timer for measuring small intervals, such as the duration of a subroutine or other reasonably small period.
StopWatch elapsed;

elapsed.start;

// do something
// ...

double i = elapsed.stop;


The measured interval is in units of seconds, using floating- point to represent fractions. This approach is more flexible than integer arithmetic since it migrates trivially to more capable timer hardware (there no implicit granularity to the measurable intervals, except the limits of fp representation)

StopWatch is accurate to the extent of what the underlying OS supports. On linux systems, this accuracy is typically 1 us at best. Win32 is generally more precise.

There is some minor overhead in using StopWatch, so take that into account

void start();
Start the timer

double stop();
Stop the timer and return elapsed duration since start()

@property ulong microsec();
Return elapsed time since the last start() as microseconds


Page generated by Ddoc. Copyright (c) 2007 Kris Bell. All rights reserved