https://code.dlang.org/packages/chimpfella

Haven't finished documenting it yet.

This uses enormous amounts of static this and that and templates, so expect vague error messages (I have tried to catch obvious errors early using static asserts but they aren't magic).

This will soon support Linux's perf_event so you will be able to measure cache misses (and all the other thousands of pmc's intel expose), use LBR msrs etc.

Quick code sample:

If for some reason you wanted to measure how many CPUID's it takes to make your cpu literally useless, you'd write this code (the ctfeRepeater helper function is because dmd doesn't like map at compile time)

static string ctfeRepeater(int n)
{
    return "cpuid;".repeat(n).join();
}

enum cpuidRange = iota(1, 10).map!(ctfeRepeater).array;
@TemplateBenchmark!(0, cpuidRange)
@FunctionBenchmark!("Measure", iota(1, 10), (_) => [1, 2, 3, 4])(meas)
static int sum(string asmLine)(inout int[] input)
{
//This is quite fun because ldc will sometimes get rid of the entire function body and just loop over the asm's
    int tmp;
    foreach (i; input)
    {
        mixin("asm { ", asmLine, ";}");
    }
    return tmp;
}


  • Chimpfella - new li... Max Haughton via Digitalmars-d-announce

Reply via email to