www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Chimpfella - new library to do benchmarking with ranges (even with

reply Max Haughton <maxhaton gmail.com> writes:
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;
}
Dec 18 2020
next sibling parent reply =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= writes:
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!
Dec 19 2020
parent reply =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= writes:
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
Dec 19 2020
parent Max Haughton <maxhaton gmail.com> writes:
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.
Dec 19 2020
prev sibling parent reply welkam <wwwelkam gmail.com> writes:
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?
Dec 20 2020
parent Max Haughton <maxhaton gmail.com> writes:
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).
Dec 20 2020