-
-
Notifications
You must be signed in to change notification settings - Fork 984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibility to benchmark asynchronous methods #236
Comments
Been doing some poor async benchmarking here dotnet/roslyn#10449 (comment) |
@benaadams "always a-void |
@AndreyAkinshin ok, the code is ready for code review In general I was not sure how to implement this one 100% correctly. Some of the ideas I had was to use ETW events to get time execution, write custom task scheduler that would measure it on it's own etc.. But all of these were limited (no .NET Core support, no custom schedulers support). So I decided to go with simpler approach:
Sample code: [Benchmark]
public Task<int> ReturningGenericTask() => // some async implementation goes here Sample auto-generated program.cs file: public Program()
{
setupAction = () => { };
cleanupAction = () => { };
idleAction = Idle;
targetAction = () => { return BenchmarkDotNet.Running.TaskMethodInvoker<System.Int32>.ExecuteBlocking(ReturningGenericTask); };
}
private System.Int32 value;
private Action setupAction;
private Action cleanupAction;
private Func<System.Int32> targetAction;
private Func<System.Int32> idleAction;
public void RunBenchmark()
{
new MethodInvoker().Invoke(job, 1, setupAction, targetAction, cleanupAction, idleAction);
}
private System.Int32 Idle()
{
return BenchmarkDotNet.Running.TaskMethodInvoker<System.Int32>.Idle();
} |
@adamsitnik On another note (and I'm not sure if it really fits in the project) testing how long does a single execution of an async method take is somewhat less useful since async improves scalability by sacrificing the performance of single executions. |
@adamsitnik @i3arnon been trying to benchmark impact to threadpool changes with a depth vs parallel matrix https://github.com/benaadams/ThreadPoolTaskTesting A similar approach might capture the scalability metric? |
@i3arnon Thanks for the hint! I have measured Host Process Environment Information:
BenchmarkDotNet-Dev.Core=v0.9.8.0
OS=Windows
Processor=?, ProcessorCount=8
Frequency=2338336 ticks, Resolution=427.6545 ns, Timer=TSC
CLR=CORE, Arch=64-bit ? [RyuJIT]
GC=Concurrent Workstation
JitModules=?
dotnet cli version: 1.0.0-preview2-003121
Type=Waiting Mode=Throughput GarbageCollection=Concurrent Workstation
LaunchCount=1
|
@i3arnon I 100% agree with you. For me the biggest advantage will be to have the possibility to check Tasks vs ValueTasks scenarios. |
@benaadams @i3arnon good ideas! I popose that you create new issue for that, we gather all the ideas, then I do some research and implement it. I know that @AndreyAkinshin has also some ideas for concurrent benchmarks for 1.0 |
@adamsitnik, the
Yep, concurrent benchmarks are in the roadmap. But it's not easy to add this feature because of some CPU "features" like false sharing. Also it requires major changes of MethodInvoker because we have to change the current approach with fixed amount of iterations. |
I would like to add support for benchmarking asynchronous methods.
Please post your requirements here, I want to know what people need.
What should be supported:
Task<T>
returning methodsTask
returning methodsValueTask<T>
returning methods (since we target .NET 4.5 we can have it!)async void
returning methods (edit: we throw NotSupportedException in that case)The text was updated successfully, but these errors were encountered: