-
Notifications
You must be signed in to change notification settings - Fork 172
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
Improve performance when generating with a specific locale #1286
Improve performance when generating with a specific locale #1286
Conversation
Nulls were interpreted as no attempt to load If values were missing for the specified locale, the `loadValues` method returned null instead of an empty map, resulting in subsequent attempts to load values into the cache.
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #1286 +/- ##
============================================
- Coverage 92.35% 91.95% -0.41%
- Complexity 2821 3086 +265
============================================
Files 292 310 +18
Lines 5609 6025 +416
Branches 599 627 +28
============================================
+ Hits 5180 5540 +360
- Misses 275 333 +58
+ Partials 154 152 -2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for this PR. Any chance you add a small unit / performance test to this to prevent regressions? |
I think adding performance tests as unit tests may not be a good practice due to the execution time. I see that the benchmarks are in the separate repository https://github.com/datafaker-net/datafaker-benchmark. Should I add a new benchmark there? |
yep, benchmark might be a good idea |
We have a few lightweight performance tests as part of the build, so it depends a bit on how long the test run is. If it's 10 seconds, it should be fine to add it to this build, if it's more then that, perhaps Datafaker-benchmark might be better. |
I have added a new banchmark: datafaker-net/datafaker-benchmark#25 Before changes:
After changes:
It gets a little better, but the difference is still significant for some reason. |
@bodiam @snuyanzin Could you please release DF 2.3.1 with this fix? |
Yes, can do, but I was hoping to release this one too: #1281 |
Overview
This is a partial fix for the issue #1285.
Result before changes:
Result after changes:
Result with no locale:
Results are based on the code here: https://github.com/vitaly-ivanov/datafaker-memory-leak/blob/main/app/src/main/kotlin/org/example/Performance.kt
Details
Nulls were interpreted as no attempt to load
If values were missing for the specified locale, the
loadValues
method returned null instead of an empty map, resulting in subsequent attempts to load values into the cache.