Convert no longer necessary lambda expressions to method groups#6726
Convert no longer necessary lambda expressions to method groups#6726smoogipoo merged 1 commit intoppy:masterfrom
Conversation
Please benchmark. 99% of the work in this PR is verifying that the dotnet issue mentioned in comments is fixed, not applying the obvious change. I'm kind of at the point where I'm no longer willing to suck it up and just test it myself. |
|
Just ran what was in dotnet/runtime#33747, and it seems fixed:
|
|
Please benchmark directly via our direct usage site, not via that reproducer. I'm not trying to be unreasonable, compilers are weird and sometimes they fail to optimise if an optimisation site is too indirect to be recognisable for the optimisation. |
|
During .NET 6 times to compare (checked out 2c9e7a6, and reverted that commit):
master:
Manually renamed to A janky benchmark with unrealistic input order, doesn't hit the line if ctrl is first then f1 (adding using BenchmarkDotNet.Attributes;
using osu.Framework.Input;
using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osuTK.Input;
namespace osu.Framework.Benchmarks
{
[MemoryDiagnoser]
public partial class MethodGroupBenchmarks
{
[Benchmark]
public void ByDelegate()
{
// use FrameworkActionContainer as it has DefaultKeyBindings
var keyBindingContainer = new TestFrameworkActionContainer();
for (int i = 0; i < 1000; i++)
{
keyBindingContainer.TriggerEvent(new KeyDownEvent(new InputState(), Key.F1));
keyBindingContainer.TriggerEvent(new KeyDownEvent(new InputState(), Key.ControlLeft));
keyBindingContainer.TriggerEvent(new KeyUpEvent(new InputState(), Key.F1));
keyBindingContainer.TriggerEvent(new KeyUpEvent(new InputState(), Key.ControlLeft));
}
}
private partial class TestFrameworkActionContainer : FrameworkActionContainer
{
public TestFrameworkActionContainer()
{
ReloadMappings();
}
}
}
}This is my first time benchmarking something, so sorry if this isn't the proper way. |
d52b2da to
633d502
Compare
Noticed in passing. Mentioned Issues are closed, but I haven't tested performance.