dotnet / dotnet/BenchmarkDotNet
StackOverflow when adding empty IterationSetup method
- Dominant language
- C#
- Stars
- 11.5k
- Forks
- 1.1k
- Avg merge
- 6d 11h
- Merged PRs (30d)
- 12
Description
Hi. I'm trying to test performance of some `ILogger` extensions that use a lot of lambdas.
Benchmarks has the following structure
```
[HtmlExporter]
[MarkdownExporter]
[MemoryDiagnoser]
[MaxColumn, MinColumn, MeanColumn]
public class LoggingBenchmark
{
MyLogger _logger = new();
[GlobalSetup]
public void GlobalSetup()
{
_logger = new MyLogger();
}
// [IterationSetup]
public void IterationSetup()
{
}
[Params(1, 10, 100, 1000)]
public int Depth { get; set; }
[Benchmark]
public Task Logger_ExecuteAsync()
{
return Helper.RunRecursively_ExecuteAsync(_logger, Depth);
}
}
```
The helper method is the equivalent of
```
Task RunRecursively_ExecuteAsync(ILogger logger, int depth)
{
return logger.ExecuteAsync(async () =>
{
return depth == 0 ? 42 : await RunRecursively_ExecuteAsync(logger, depth - 1);
})
}
```
`ExecuteAsync` is just an extension that does `try/catch` around async action and logs some stuff
For some reason i'm getting stack overflow exception when uncommenting `// [IterationSetup]` attribute, even though the method is empty.
Any immediate thoughts about the difference, before i invest into making full repro? Looks a bit odd on my end
StackOverflow is obviously for the `Depth = 1000` case, runs out of stack arfet 800 or so.
BenchmarkDotNet version: `0.14.0`
Contributor guide
Assessment
This issue has not been assessed yet.