datafaker-net / datafaker

Generating fake data for the JVM (Java, Kotlin, Groovy) has never been easier!
https://www.datafaker.net
Apache License 2.0
1.16k stars 160 forks source link

Locale specific generation performance degradation #1285

Closed vitaly-ivanov closed 3 months ago

vitaly-ivanov commented 3 months ago

Describe the bug In the latest version, I found a performance hit when the locale is specified.

No locale: Time to process 1000000 values: 2.310795584s

Locale en-GB: Time to process 1000000 values: 40.341209708s

The results are not precise but the difference is abnormal.

To Reproduce Code to reproduce is here: https://github.com/vitaly-ivanov/datafaker-memory-leak/blob/main/app/src/main/kotlin/org/example/Performance.kt

Expected behavior Similar execution time for both cases, whether locale is set or not.

Versions:

Additional context I will send a PR soon with a bugfix that improves performance, but the results with the locale specified are still not as good as without.

vitaly-ivanov commented 3 months ago

Interim findings.

After the changes from https://github.com/datafaker-net/datafaker/pull/1286 the flame graph looks like this:

With locale: flamegraph

No locale: flamegraph2