Thread overview
Chimpfella - new library to do benchmarking with ranges (even with templates!)
Dec 21
welkam
December 19
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;
}


December 19
On Saturday, 19 December 2020 at 05:08:56 UTC, Max Haughton wrote:
> https://code.dlang.org/packages/chimpfella
>
> Haven't finished documenting it yet.
>
> [...]

...
@wrapper
function()
...

I like it!
December 19
On Saturday, 19 December 2020 at 08:30:09 UTC, Виталий Фадеев wrote:
> On Saturday, 19 December 2020 at 05:08:56 UTC, Max Haughton wrote:
>> https://code.dlang.org/packages/chimpfella
>>
>> Haven't finished documenting it yet.
>>
>> [...]
>
> ...
> @wrapper
> function()
> ...
>
> I like it!

and I want some like this for memory:
  save process memory
  call func()
  print memory delta


December 19
On Saturday, 19 December 2020 at 09:39:49 UTC, Виталий Фадеев wrote:
> On Saturday, 19 December 2020 at 08:30:09 UTC, Виталий Фадеев wrote:
>> On Saturday, 19 December 2020 at 05:08:56 UTC, Max Haughton wrote:
>>> https://code.dlang.org/packages/chimpfella
>>>
>>> Haven't finished documenting it yet.
>>>
>>> [...]
>>
>> ...
>> @wrapper
>> function()
>> ...
>>
>> I like it!
>
> and I want some like this for memory:
>   save process memory
>   call func()
>   print memory delta

Memory is a bit harder but I will add it.
December 21
On Saturday, 19 December 2020 at 05:08:56 UTC, Max Haughton wrote:

> 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.
Are you going to read stdout from calling perf or are you going to read perf.data file?
December 21
On Monday, 21 December 2020 at 03:27:14 UTC, welkam wrote:
> On Saturday, 19 December 2020 at 05:08:56 UTC, Max Haughton wrote:
>
>> 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.
> Are you going to read stdout from calling perf or are you going to read perf.data file?

I already have code that uses perf_event_open directly, it's much more efficient at the expense of having to decipher shit linux documentation. I tried to get the bindings into druntime but they weren't up to snuff apparently.

The architecture of the counters is designed around a stateless widget giving you a stateful gadget specifically because this makes using perf_event_open less of a minefield.

You can also enable userspace-rdpmc, which I will support eventually (but you get a general protection fault if something goes wrong so it's hard to debug).