I have a method that needs to iterate on a collection (a DataRowCollection, to be precise).
The current implementation is a little slow, so I’ve been trialing a faster one. I’ve used BenchmarkDotNet to compare execution time with identical parameters, and it is noticeably faster given a sufficiently large collection.
My suspicion is that this won’t be the case if the collection is relatively small. As such, I’d really like to compare how the two scale: which is faster at 1, 10, 100, 1,000, 10,000 elements?
Best as I can tell, BenchmarkDotNet has no built-in facility for this. What I’d like is to pass it a reference to the collection, and for it to execute the methods with different sizes or slices. (Such as by copying it to ILists of different sizes.)
Basically, to end up with charts like on http://ridiculousfish.com/blog/posts/array.html
[Params(1, 10, 100, 1000, 10000)]
public int Size { get; set; }
then use Size
in your tests. It should output etc automatically. You can also use parameterized values in any pre-test [GlobalSetup]
method, for example to pre-initialize a list/array so that it isn't counted in the benchmark.