On 7/22/15 5:23 AM, Clayton wrote:
How does one represent Duration in only Micro-seconds, or milliseconds.
Trying to measure the execution time of an algorithm and I get "4 ms,
619 μs, and 8 hnsecs" , I want to sum all these and get total hnsecs or
μs .
I would also appreciate advise on whether this is the best way to
measure the execution time of an algorithm.
import std.datetime;
import std.stdio;
void algorithm( ){
writeln("Hello!");
}
void main(){
auto stattime = Clock.currTime();
algorithm( );
endttime = Clock.currTime();
auto duration = endttime - stattime;
writeln("Hello Duration ==> ", duration);
}
I know John identified Stopwatch, but just an FYI, Duration has the
method total: http://dlang.org/phobos/core_time.html#.Duration.total
I think doing:
writeln("Hello Duration ==> ", duration.total!"usecs");
would also work.
-Steve