dotnet / dotnet/performance

Question about extracting test to standalone app.

Open
#2,267 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
F#
Stars
773
Forks
301
Avg merge
6d 9h
Merged PRs (30d)
15

Description

I have a question about extracting microbenchmark [test](https://github.com/dotnet/performance/blob/main/src/benchmarks/micro/libraries/System.Threading/Perf.Interlocked.cs)s to standalone apps – I want to extract a test from ‘System.Threading’ ( test ) . I went through the write-up in the [repro](https://github.com/dotnet/performance/blob/main/docs/profiling-workflow-dotnet-runtime.md#repro), but these seem to deal with primarily single threaded tests. This wouldn’t make any sense for something like ‘System.Threading.Tests.Perf_[Interlocked](https://docs.microsoft.com/en-us/dotnet/api/system.threading.interlocked?view=net-6.0).Add_int’. My understanding based on documentation there is boilerplate code is created for tests are based on the config particular to the test. I do not see any specific config for ‘System.Threading.*’ test which would cause it to have boilerplate code created with threading in mind. If I were to simply insert the call being tested, I’ll end up with something like below. I might be missing something here but it doesn’t really seem to test any relevant scenario for Interlocked since multiple threads will not be accessing the variable at the same time

static int Main()
{
Stopwatch sw = new Stopwatch();
sw.Start();
int intVal = 0;
for (int i = 0; i < 900_000_000; i++)
{
Interlocked.Add(ref intVal, 2);
}

sw.Stop();

Console.WriteLine("Elapsed={0}", sw.Elapsed);

return (int)intVal;
}

1. Is there some config used which I missed that creates boilerplate code more suited for testing this?
2. Is there a way to dump the boilerplate code created? [Disassembly-Diagnoser](https://adamsitnik.com/Disassembly-Diagnoser/) is the closest I found. But I managed to dump only disasm for a particular func with that and not the boilerplate code.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.