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

Optimize English to words converter #1463

Merged
merged 6 commits into from
Feb 25, 2024
Merged

Conversation

hazzik
Copy link
Member

@hazzik hazzik commented Feb 25, 2024

Remove recursion & reduce allocations.

Before:


BenchmarkDotNet v0.13.12, Windows 10 (10.0.19045.4046/22H2/2022Update)
12th Gen Intel Core i7-12800H, 1 CPU, 20 logical and 14 physical cores
.NET SDK 8.0.201
  [Host]     : .NET 8.0.2 (8.0.224.6711), X64 RyuJIT AVX2
  DefaultJob : .NET 8.0.2 (8.0.224.6711), X64 RyuJIT AVX2


Method Mean Error StdDev Gen0 Allocated
ToWords 333.2 ns 6.70 ns 19.22 ns 0.1316 1.62 KB
ToWordsOrdinal 366.2 ns 8.01 ns 23.37 ns 0.1349 1.66 KB

After:


BenchmarkDotNet v0.13.12, Windows 10 (10.0.19045.4046/22H2/2022Update)
12th Gen Intel Core i7-12800H, 1 CPU, 20 logical and 14 physical cores
.NET SDK 8.0.201
  [Host]     : .NET 8.0.2 (8.0.224.6711), X64 RyuJIT AVX2
  DefaultJob : .NET 8.0.2 (8.0.224.6711), X64 RyuJIT AVX2


Method Mean Error StdDev Gen0 Allocated
ToWords 136.9 ns 2.79 ns 8.13 ns 0.0489 616 B
ToWordsOrdinal 150.0 ns 3.18 ns 9.37 ns 0.0522 656 B

@hazzik hazzik marked this pull request as ready for review February 25, 2024 13:06
@hazzik hazzik enabled auto-merge (squash) February 25, 2024 13:14
@hazzik hazzik added the perf label Feb 25, 2024
@hazzik hazzik added this to the v3.0 milestone Feb 25, 2024
@hazzik hazzik merged commit 1e2bbc9 into Humanizr:main Feb 25, 2024
3 checks passed
@hazzik hazzik deleted the optimize-en-to-words branch February 25, 2024 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants