Skip to content
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

Use cached delegates to set property values rather than SetValue #170

Merged
merged 2 commits into from
Aug 29, 2018

Conversation

Mpdreamz
Copy link
Contributor

Using the following Fake context to generate 10,000 items:

FakerWithRules = new Faker<Project>()
    .CustomInstantiator(f=> new Project())
    .RuleFor(p=>p.Id, f => f.IndexGlobal)
    .UseSeed(1337);

Old (SetValue):

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Generate_WithRules 6.770 ms 0.0624 ms 0.0584 ms 265.6250 109.3750 31.2500 1.55 MB

New (Cached setter delegate):

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Generate_WithRules 4.046 ms 0.0251 ms 0.0235 ms 164.0625 93.7500 31.2500 960.09 KB

@bchavez
Copy link
Owner

bchavez commented Aug 29, 2018

Hi Martijn,

Thank you for the performance improvements. I'm also seeing the same results!

Thanks again for your help and PR! New release coming out shortly.
Brian

⚫ 💫 "Black magic... bla-a-a-ack... black magic..."

BenchmarkDotNet=v0.10.14, OS=Windows 7 SP1 (6.1.7601.0)
Intel Core i7-3960X CPU 3.30GHz (Ivy Bridge), 1 CPU, 12 logical and 6 physical cores
Frequency=3224638 Hz, Resolution=310.1123 ns, Timer=TSC
  [Host]     : .NET Framework 4.7.1 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.2558.0
  DefaultJob : .NET Framework 4.7.1 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.2558.0
Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Generate_WithRules 7.394 ms 0.0414 ms 0.0387 ms 265.6250 109.3750 31.2500 1.55 MB
Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Generate_WithRules 4.296 ms 0.0340 ms 0.0318 ms 164.0625 101.5625 31.2500 960.11 KB

@bchavez bchavez merged commit 04efeb0 into bchavez:master Aug 29, 2018
bchavez added a commit that referenced this pull request Sep 27, 2018
… couldn't find a public setter. This change allows setting of non-public members. Reverts back to previous Bogus behavior which originally allowed setting of non-public members. Related #179.
bchavez added a commit that referenced this pull request Sep 27, 2018
… couldn't find a public setter. This change allows setting of non-public members. Reverts back to previous Bogus behavior which originally allowed setting of non-public members. Related #179.
bchavez added a commit that referenced this pull request Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants