Skip to content

Commit c00bee6

Browse files
CopilotPhenX
andcommitted
Use SyntaxFactory for registry emission; expose reflection path; add benchmark comparison
Co-authored-by: PhenX <42170+PhenX@users.noreply.github.com>
1 parent ed52f77 commit c00bee6

3 files changed

Lines changed: 442 additions & 241 deletions

File tree

benchmarks/EntityFrameworkCore.Projectables.Benchmarks/ExpressionResolverBenchmark.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ namespace EntityFrameworkCore.Projectables.Benchmarks
88
{
99
/// <summary>
1010
/// Micro-benchmarks <see cref="ProjectionExpressionResolver.FindGeneratedExpression"/> in
11-
/// isolation (no EF Core overhead) to directly compare the registry lookup path against
12-
/// the previous per-call reflection chain.
11+
/// isolation (no EF Core overhead) to directly compare the static registry path against
12+
/// the reflection-based path (<see cref="ProjectionExpressionResolver.FindGeneratedExpressionViaReflection"/>).
1313
/// </summary>
1414
[MemoryDiagnoser]
1515
public class ExpressionResolverBenchmark
@@ -25,16 +25,32 @@ public class ExpressionResolverBenchmark
2525

2626
private readonly ProjectionExpressionResolver _resolver = new();
2727

28+
// ── Registry (source-generated) path ─────────────────────────────────
29+
2830
[Benchmark(Baseline = true)]
29-
public LambdaExpression? ResolveProperty()
31+
public LambdaExpression? ResolveProperty_Registry()
3032
=> _resolver.FindGeneratedExpression(_propertyMember);
3133

3234
[Benchmark]
33-
public LambdaExpression? ResolveMethod()
35+
public LambdaExpression? ResolveMethod_Registry()
3436
=> _resolver.FindGeneratedExpression(_methodMember);
3537

3638
[Benchmark]
37-
public LambdaExpression? ResolveMethodWithParam()
39+
public LambdaExpression? ResolveMethodWithParam_Registry()
3840
=> _resolver.FindGeneratedExpression(_methodWithParamMember);
41+
42+
// ── Reflection path ───────────────────────────────────────────────────
43+
44+
[Benchmark]
45+
public LambdaExpression? ResolveProperty_Reflection()
46+
=> ProjectionExpressionResolver.FindGeneratedExpressionViaReflection(_propertyMember);
47+
48+
[Benchmark]
49+
public LambdaExpression? ResolveMethod_Reflection()
50+
=> ProjectionExpressionResolver.FindGeneratedExpressionViaReflection(_methodMember);
51+
52+
[Benchmark]
53+
public LambdaExpression? ResolveMethodWithParam_Reflection()
54+
=> ProjectionExpressionResolver.FindGeneratedExpressionViaReflection(_methodWithParamMember);
3955
}
4056
}

0 commit comments

Comments
 (0)