Benchmarking in D

Chris Mueller ruunhb at googlemail.com
Sun Apr 11 15:05:42 PDT 2010


> There's the benchmark() function in Phobos:
> http://www.digitalmars.com/d/2.0/phobos/std_date.html#benchmark
>
> Don't know if that's what you're really looking for, though.

...

> void bench(R)(string label, R delegate() dg, uint times = 1 ) {
>     scope pc = new PerformanceCounter;
>     real time = uint.max;
>     foreach(i;0..times) {
>         pc.start;
>         dg();
>         pc.stop;
>         time = min(time,pc.microseconds/1000.0);
>         Thread.yield;
>     }
>     writeln(label,time,"ms");
> }

yep, that's what i'm missing. I give a try some of your benchmark 
suggestions for time measurements.

> On what OS? On linux, you can do:
>
> time foo
> 	to get the run time for program foo, including elapsed clock time,
> time spent in the program itself and time spent in the kernel on
> behalf of the program (for I/O, mallocs, etc);
>
> cat /proc/$(pidof foo)/status
> 	to get memory information for a running program. I don't know any
> way to get the memory information once the program exits.
>

I'm currently using XP, is there any similar way to measure memory
consumption? Otherwise i install a quick unix development environment
on a separate partition.

Thanks for your replies.

Chris


-- 
ruunhb at googlemail.com
http://ruuns.de/blog/



More information about the Digitalmars-d mailing list