Skip to content

Avoid lambda compilation for constant and member access expressions in Criteria #2448

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

Merged
merged 2 commits into from
Jul 28, 2020

Conversation

bahusoid
Copy link
Member

@bahusoid bahusoid commented Jul 23, 2020

//Example of constant
query.Where(x => x.Id == 1);

//Example of member access
var paramId = 1;
query.Where(x => x.Id == paramId)

@hazzik
Copy link
Member

hazzik commented Jul 24, 2020

@bahusoid is performance gain significant?

@bahusoid
Copy link
Member Author

bahusoid commented Jul 25, 2020

@hazzik Benchmark for member access case (Where(x => x.Id == paramId)):

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.18363.959 (1909/November2018Update/19H2)
Intel Core i5-5200U CPU 2.20GHz (Broadwell), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=3.1.201
  [Host]     : .NET Core 2.1.17 (CoreCLR 4.6.28619.01, CoreFX 4.6.28619.01), X64 RyuJIT
  DefaultJob : .NET Core 2.1.17 (CoreCLR 4.6.28619.01, CoreFX 4.6.28619.01), X64 RyuJIT
| Method |       Mean |     Error |     StdDev | Ratio |
|------- |-----------:|----------:|-----------:|------:|
|    New |   1.562 us | 0.0283 us |  0.0236 us | 0.007 |
|    Old | 233.980 us | 4.6614 us | 12.1980 us | 1.000 |

  1 us   : 1 Microsecond (0.000001 sec)

Source: https://gist.github.com/bahusoid/c68cb6b81f8dde9252d0cc67229136b4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants