Measuring Execution time

Clayton via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 22 02:23:35 PDT 2015


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);

}


More information about the Digitalmars-d-learn mailing list