Skip to content

Commit f827d3a

Browse files
committed
normal Func speed is faster
1 parent ffe9458 commit f827d3a

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

test/FastExpressionCompiler.Benchmarks/Issue468_Compile_vs_FastCompile.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ .NET SDK 9.0.203
3636
| InvokeCompiledFast | .NET 9.0 | .NET 9.0 | 1.0640 ns | 0.0539 ns | 0.0929 ns | 1.0106 ns | 1.01 | 0.12 | 2 | 2 | 0 | 0 | - | NA |
3737
| InvokeCompiled | .NET 9.0 | .NET 9.0 | 0.5897 ns | 0.0451 ns | 0.0858 ns | 0.6156 ns | 0.56 | 0.09 | 1 | 1 | -0 | -0 | - | NA |
3838
39-
## Steal the same speed with the minimal IL of 2 instructions
39+
40+
## Steel the same speed with the minimal IL of 2 instructions
4041
4142
Job=.NET 8.0 Runtime=.NET 8.0
4243
@@ -45,14 +46,24 @@ .NET SDK 9.0.203
4546
| InvokeCompiled | 0.4647 ns | 0.0321 ns | 0.0268 ns | 1.00 | 0.08 | 1 | - | NA |
4647
| InvokeCompiledFast | 0.9739 ns | 0.0433 ns | 0.0481 ns | 2.10 | 0.15 | 2 | - | NA |
4748
49+
50+
## But the Func speed is faster, hmm
51+
52+
Job=.NET 8.0 Runtime=.NET 8.0
53+
54+
| Method | Mean | Error | StdDev | Ratio | RatioSD | Rank | Allocated | Alloc Ratio |
55+
|--------------- |----------:|----------:|----------:|------:|--------:|-----:|----------:|------------:|
56+
| InvokeCompiled | 0.2685 ns | 0.0210 ns | 0.0186 ns | 1.00 | 0.09 | 2 | - | NA |
57+
| JustFunc | 0.1711 ns | 0.0310 ns | 0.0305 ns | 0.64 | 0.12 | 1 | - | NA |
58+
4859
*/
4960
[MemoryDiagnoser, RankColumn]
5061
// [HardwareCounters(HardwareCounter.CacheMisses, HardwareCounter.BranchMispredictions, HardwareCounter.BranchInstructions)]
5162
// [SimpleJob(RuntimeMoniker.Net90)]
5263
[SimpleJob(RuntimeMoniker.Net80)]
5364
public class Issue468_InvokeCompiled_vs_InvokeCompiledFast
5465
{
55-
Func<bool> _compiled, _compiledFast;
66+
Func<bool> _compiled, _compiledFast, _justFunc = static () => true;
5667

5768
[GlobalSetup]
5869
public void Setup()
@@ -68,11 +79,17 @@ public bool InvokeCompiled()
6879
return _compiled();
6980
}
7081

71-
[Benchmark]
82+
// [Benchmark]
7283
public bool InvokeCompiledFast()
7384
{
7485
return _compiledFast();
7586
}
87+
88+
[Benchmark]
89+
public bool JustFunc()
90+
{
91+
return _justFunc();
92+
}
7693
}
7794

7895
/*

0 commit comments

Comments
 (0)