How to benchmark an interface class?

59 views
Skip to first unread message

royk...@gmail.com

unread,
May 30, 2020, 5:31:34 PM5/30/20
to benchmark-discuss
First of all if someone could link a documentation I would be grateful since the github readme doesn't explain the api in detail and I have to do alot of guesses.
Okay, I have a an abstract class Allocator and I have multiple derived classes. I want to benchmark each derived function implementation with a set of arguments.

The first argument supposed to be a vector of allocation sizes like:
1,2,4,8,..65536
And the second argument supposed to be an allocator object like:
LinearAllocator a;

How would I pass this vector and allocator object to a benchmark?
Also how would I pass a range of allocator so multiple benchmark for each allocator type are run with the same vector of allocation sizes?

Dominic Hamon

unread,
Jun 1, 2020, 5:45:51 AM6/1/20
to royk...@gmail.com, benchmark-discuss
Hi Roy

Please feel free to file any feature request issues on github with specific things you think are missing from the docs. I thought we were fairly comprehensive but if we're missing stuff you need i'd like to know.

For your specific question I'm not sure i understand enough about your needs to help. Let me repeat back what i think you're saying so i can help:

You have a function defined by multiple classes and you'd like to benchmark the different implementations. Have you figured out how to use templated benchmarks to pass the different derived class types to the benchmark? I believe this would be the allocator type in your example.

For the allocation sizes, you don't need to pass it in to the benchmark. You can either define it globally or in a fixture. Note that templated fixtures are also supported which might help your case.

If you can provide a link to your current attempt then I can maybe provide some more specific pointers.

Dominic Hamon | Google
There are no bad ideas; only good ideas that go horribly wrong.


--
You received this message because you are subscribed to the Google Groups "benchmark-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to benchmark-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/benchmark-discuss/36c8ea8e-9807-457f-a356-d9ed6fc94d57%40googlegroups.com.

royk...@gmail.com

unread,
Jun 2, 2020, 2:16:45 PM6/2/20
to benchmark-discuss
Okay using template benchmark function can really solve the problem, but an issue with my allocator implementations is that some takes different args in their ctor so one benchmark template function to test them all is impossible. But what I did is use one normal benchmark function with DenseArg [0, number_of_different_allocators] and in the bench mark function I call a GetAllocator(std::size_t index) function that given an index return the allocator implementation through a base pointer.

בתאריך יום ראשון, 31 במאי 2020 בשעה 00:31:34 UTC+3, מאת royk...@gmail.com:

royk...@gmail.com

unread,
Jun 3, 2020, 7:14:22 PM6/3/20
to benchmark-discuss
Also regarding docs update I think state.KeepRunning() should be explained, I see it can control threaded test, but in the basic usage where no threaded test its used as-well so there's more to this function than explained on the readme I think.

בתאריך יום שלישי, 2 ביוני 2020 בשעה 21:16:45 UTC+3, מאת royk...@gmail.com:

Dominic Hamon

unread,
Jun 9, 2020, 11:30:09 AM6/9/20
to royk...@gmail.com, benchmark-discuss
KeepRunning is largely deprecated in favour of the auto loop over state. KeepRunningBatch is a special case that runs a specific number of iterations in one go, which can help limit overhead. For threaded tests, it's not KeepRunning you want, but the thread_index from state, i think.
 
Dominic Hamon | Google
There are no bad ideas; only good ideas that go horribly wrong.

--
You received this message because you are subscribed to the Google Groups "benchmark-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to benchmark-disc...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages