On Sun, 11 Apr 2010 05:27:58 -0300, Chris Mueller <[email protected]> wrote:

Hi everyone,

I would like to benchmark some of my D routines for performance testing and like to compare it with some alternative implementations in e.g. time and memory consumption.

I'm not really experienced in this field and want to ask if someone can share his knowledge.

Are there some tools providing by the operating system to look at the
performance of a process? Are there any libraries in D that can help?


Chris

Here's a little benchmark routine I use:

import std.perf;
import core.thread;
import std.stdio;
import std.algorithm;

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

Reply via email to