Skip to content

Commit 8197a45

Browse files
committed
funny bms #472
1 parent 75afd5d commit 8197a45

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

test/FastExpressionCompiler.Benchmarks/Issue468_Compile_vs_FastCompile.cs

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,32 @@ Using this latter (System) overload drastically slows down the compilation but r
7474
| InvokeCompiled | 0.5075 ns | 0.0153 ns | 0.0143 ns | 1.00 | 0.04 | 1 | 1 | - | NA |
7575
| InvokeCompiledFast | 0.5814 ns | 0.0433 ns | 0.0699 ns | 1.15 | 0.14 | 1 | 1 | - | NA |
7676
77+
## Not with full eval before Compile the results are funny in the good way
78+
79+
80+
Job=.NET 8.0 Runtime=.NET 8.0
81+
82+
| Method | Mean | Error | StdDev | Ratio | RatioSD | Rank | BranchInstructions/Op | Allocated | Alloc Ratio |
83+
|------------------------------- |----------:|----------:|----------:|------:|--------:|-----:|----------------------:|----------:|------------:|
84+
| InvokeCompiled | 0.5071 ns | 0.0289 ns | 0.0242 ns | 1.00 | 0.06 | 2 | 1 | - | NA |
85+
| InvokeCompiledFastWithEvalFlag | 0.0804 ns | 0.0341 ns | 0.0351 ns | 0.16 | 0.07 | 1 | 1 | - | NA |
86+
7787
*/
7888
[MemoryDiagnoser, RankColumn]
7989
[HardwareCounters(HardwareCounter.BranchInstructions)]
8090
// [SimpleJob(RuntimeMoniker.Net90)]
8191
[SimpleJob(RuntimeMoniker.Net80)]
8292
public class Issue468_InvokeCompiled_vs_InvokeCompiledFast
8393
{
84-
Func<bool> _compiled, _compiledFast, _justFunc = static () => true;
94+
Func<bool> _compiled, _compiledFast, _compiledFastWithEvalFlag, _justFunc = static () => true;
8595

8696
[GlobalSetup]
8797
public void Setup()
8898
{
8999
var expr = IssueTests.Issue468_Optimize_the_delegate_access_to_the_Closure_object_for_the_modern_NET.CreateExpression();
90100
_compiled = expr.CompileSys();
91-
_compiledFast = expr.CompileFast(flags: CompilerFlags.TryEvalPureArithmeticAndLogic);
101+
_compiledFast = expr.CompileFast();
102+
_compiledFastWithEvalFlag = expr.CompileFast(flags: CompilerFlags.TryEvalPureArithmeticAndLogic);
92103
}
93104

94105
[Benchmark(Baseline = true)]
@@ -97,12 +108,18 @@ public bool InvokeCompiled()
97108
return _compiled();
98109
}
99110

100-
[Benchmark]
111+
// [Benchmark]
101112
public bool InvokeCompiledFast()
102113
{
103114
return _compiledFast();
104115
}
105116

117+
[Benchmark]
118+
public bool InvokeCompiledFastWithEvalFlag()
119+
{
120+
return _compiledFastWithEvalFlag();
121+
}
122+
106123
// [Benchmark]
107124
public bool JustFunc()
108125
{
@@ -134,9 +151,20 @@ public bool JustFunc()
134151
| CompiledFast | .NET 9.0 | .NET 9.0 | 3.337 us | 0.0634 us | 0.0593 us | 0.13 | 0.00 | 1 | 0.1793 | 0.1755 | 1.12 KB | 0.27 |
135152
| CompiledFast_WithEvalFlag | .NET 9.0 | .NET 9.0 | 3.198 us | 0.0628 us | 0.0588 us | 0.13 | 0.00 | 1 | 0.2365 | 0.2289 | 1.48 KB | 0.36 |
136153
154+
155+
## Funny results after adding eval before compile
156+
157+
Job=.NET 8.0 Runtime=.NET 8.0
158+
159+
| Method | Mean | Error | StdDev | Median | Ratio | RatioSD | Rank | Gen0 | Gen1 | Allocated | Alloc Ratio |
160+
|-------------------------- |------------:|----------:|----------:|------------:|-------:|--------:|-----:|-------:|-------:|----------:|------------:|
161+
| Compiled | 22,507.0 ns | 435.99 ns | 652.57 ns | 22,519.1 ns | 131.40 | 8.03 | 3 | 0.6714 | 0.6409 | 4232 B | 11.02 |
162+
| CompiledFast | 3,051.9 ns | 59.71 ns | 55.86 ns | 3,036.6 ns | 17.82 | 1.01 | 2 | 0.1755 | 0.1678 | 1143 B | 2.98 |
163+
| CompiledFast_WithEvalFlag | 171.8 ns | 3.49 ns | 9.44 ns | 167.6 ns | 1.00 | 0.08 | 1 | 0.0610 | - | 384 B | 1.00 |
164+
137165
*/
138166
[MemoryDiagnoser, RankColumn]
139-
[SimpleJob(RuntimeMoniker.Net90)]
167+
// [SimpleJob(RuntimeMoniker.Net90)]
140168
[SimpleJob(RuntimeMoniker.Net80)]
141169
public class Issue468_Compile_vs_FastCompile
142170
{
@@ -148,7 +176,7 @@ public void Setup()
148176
_expr = IssueTests.Issue468_Optimize_the_delegate_access_to_the_Closure_object_for_the_modern_NET.CreateExpression();
149177
}
150178

151-
[Benchmark(Baseline = true)]
179+
[Benchmark]
152180
public object Compiled()
153181
{
154182
return _expr.Compile();
@@ -160,7 +188,7 @@ public object CompiledFast()
160188
return _expr.CompileFast();
161189
}
162190

163-
[Benchmark]
191+
[Benchmark(Baseline = true)]
164192
public object CompiledFast_WithEvalFlag()
165193
{
166194
return _expr.CompileFast(flags: CompilerFlags.TryEvalPureArithmeticAndLogic);

test/FastExpressionCompiler.Benchmarks/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public static void Main()
2525

2626
//--------------------------------------------
2727

28-
// BenchmarkRunner.Run<Issue468_Compile_vs_FastCompile>();
29-
BenchmarkRunner.Run<Issue468_InvokeCompiled_vs_InvokeCompiledFast>();
28+
BenchmarkRunner.Run<Issue468_Compile_vs_FastCompile>();
29+
// BenchmarkRunner.Run<Issue468_InvokeCompiled_vs_InvokeCompiledFast>();
3030

3131
// BenchmarkRunner.Run<AccessByRef_vs_ByIGetRefStructImpl>();
3232

0 commit comments

Comments
 (0)