question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Slow generation on .NET 6

See original GitHub issue

When switching from .NET 5 to .NET 6, the Generate method takes over an order of magnitude longer, even for very simple records (e.g. Foo(int Bar)).

Job Runtime Mean Error StdDev Ratio RatioSD
.NET 5.0 .NET 5.0 7,574.85 ns 45.050 ns 42.139 ns 1.00 0.00
.NET 6.0 .NET 6.0 367,589.88 ns 2,163.086 ns 2,023.352 ns 48.53 0.27

Bogus does not show the same performance difference as AutoBogus:

Job Runtime Mean Error StdDev Ratio RatioSD
.NET 5.0 .NET 5.0 82.71 ns 0.111 ns 0.104 ns 1.00 0.00
.NET 6.0 .NET 6.0 71.28 ns 0.378 ns 0.353 ns 0.86 0.00

I have created a Gist with the code used to generate this benchmark.

It sounds odd that no one has noticed it before, so perhaps I’m using it wrong?

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:6

github_iconTop GitHub Comments

2reactions
paoloambrosiocommented, Jul 3, 2022

Was there a particular fix you added to make it work better?

Unfortunately, I didn’t find a way to fix it 😞 I simply noticed that tests weren’t failing anymore when sharing a single generated instance, so I’m just generating it once per test class, instead of once per test as I had to do before.

Also fwiw, I ended up publishing a forked version of Autobogus given @nickdodd79’s inactivity. It was focused on updating to .NET 6 and has pretty minimal changes, but theoretically helps this by now using .NET 6 if you want to give it a try?

I can’t see the public source code on GitHub (dead links in the NuGet page). If you want to try it yourself, the gist above contains two files: the C# project and the BenchmarkDotNet test.

1reaction
paoloambrosiocommented, Jul 4, 2022

Tried the benchmark and I get similar results with both AutoBogus 2.13.1 and AutoBogusLifeSupport 2.14.0. To be honest I didn’t see anything in the code to suggest that it would behave differently in this case, but it was worth a try 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

NET6 performance issue (compared to .NET5) #63621
After the migration the application is slow (4-5 times slower). It's not any particular part of the code that has slowed down the...
Read more >
Performance Improvements in .NET 6
Code generation is the foundation on top of which everything else is built. As such, improvements to code generation have a multiplicative ...
Read more >
Visual studio 22 slow Build time with .net core 6
net core 2.1 to .net core 6.0, the build time became slow,takes about 1:30 (1 minute and 30 seconds) . by using MSBuild...
Read more >
.NET 6 hello world extremely slow : r/csharp
When I try to run in command promt it takes 6~9 seconds to show the hello world text. Tried same in my friends...
Read more >
Improving logging performance with source generators
NET 6. In this post I look at the new LoggerMessage source generator, showing how and when to use it. I start by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found