You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In one of my BenchmarkDotNet(0.11.5) benchmarks I have a need to reuse an instance of StreamReader which I initialize once at startup and then after each iteration I reset an underlying stream in it. Like below:
I know that the docs discourage developers from using [IterationSetup] but in my case its usage looks justified.
The problem is that once I've added the method [IterationSetup] public void IterationSetup() to my code
the BenchmarkDotNet has stopped inferring the InvocationCount correctly. Instead, it always defaults to InvocationCount=1 which is not appropriate for my benchmark and probably for any other real-life benchmarks.
Is this a bug? What'd be a better way of resetting the stream in between the iterations in the code above?
The minimum code to reproduce such behavior:
[BenchmarkCategory(Categories.XYZ)]publicclassPerf_Benchmark1{[IterationSetup]publicvoidIterationSetup(){// can be just empty}[Benchmark]publicList<int>Benchmark()=>newList<int>();}
The text was updated successfully, but these errors were encountered:
Hi,
In one of my BenchmarkDotNet(0.11.5) benchmarks I have a need to reuse an instance of
StreamReader
which I initialize once at startup and then after each iteration I reset an underlying stream in it. Like below:I know that the docs discourage developers from using
[IterationSetup]
but in my case its usage looks justified.The problem is that once I've added the method
[IterationSetup] public void IterationSetup()
to my codethe BenchmarkDotNet has stopped inferring the InvocationCount correctly. Instead, it always defaults to InvocationCount=1 which is not appropriate for my benchmark and probably for any other real-life benchmarks.
Is this a bug? What'd be a better way of resetting the stream in between the iterations in the code above?
The minimum code to reproduce such behavior:
The text was updated successfully, but these errors were encountered: