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

⚡️ add benchmark for DurationParser from int array vs. span #93

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Odonno
Copy link
Contributor

@Odonno Odonno commented Mar 28, 2024

Added 2 benchmarks method to parse Duration

  • one from a string (ReadOnlySpan<char>), avoiding complex parser
  • one from a [long?, int?] array

Result:

  • less memory allocation
  • way faster (avoiding string parsing)
  • best format = [long?, int?] array
| Method     | Param          | Mean         | Error      | StdDev     | Ratio | RatioSD | Gen0   | Allocated | Alloc Ratio |
|----------- |--------------- |-------------:|-----------:|-----------:|------:|--------:|-------:|----------:|------------:|
| Superpower | 0ns            |   481.745 ns |  5.3422 ns |  4.4610 ns |  1.00 |    0.00 | 0.0429 |     720 B |        1.00 |
| Pidgin     | 0ns            |   518.948 ns |  5.8655 ns |  5.4865 ns |  1.08 |    0.02 | 0.0191 |     320 B |        0.44 |
| FromSpan   | 0ns            |    32.940 ns |  0.4281 ns |  0.3795 ns |  0.07 |    0.00 | 0.0114 |     192 B |        0.27 |
| FromArray  | 0ns            |     7.218 ns |  0.1512 ns |  0.1263 ns |  0.01 |    0.00 | 0.0048 |      80 B |        0.11 |
|            |                |              |            |            |       |         |        |           |       |
| Superpower | 5y4w3h115ms4ns | 3,410.964 ns | 29.3004 ns | 25.9740 ns |  1.00 |    0.00 | 0.1831 |    3072 B |        1.00 |
| Pidgin     | 5y4w3h115ms4ns | 2,536.325 ns | 18.6825 ns | 17.4756 ns |  0.74 |    0.01 | 0.0267 |     488 B |        0.16 |
| FromSpan   | 5y4w3h115ms4ns |   128.111 ns |  0.7486 ns |  0.6251 ns |  0.04 |    0.00 | 0.0229 |     384 B |        0.12 |
| FromArray  | 5y4w3h115ms4ns |    69.696 ns |  0.4898 ns |  0.4582 ns |  0.02 |    0.00 | 0.0229 |     384 B |        0.12 |

@codecov-commenter
Copy link

codecov-commenter commented Mar 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.32%. Comparing base (aff390a) to head (a3c5c90).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #93   +/-   ##
=======================================
  Coverage   69.32%   69.32%           
=======================================
  Files         110      110           
  Lines        4482     4482           
  Branches      438      438           
=======================================
  Hits         3107     3107           
  Misses       1155     1155           
  Partials      220      220           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Odonno Odonno changed the title ⚡️ add benchmark for DurationParser from int array ⚡️ add benchmark for DurationParser from int array vs. span Mar 30, 2024
@Odonno Odonno force-pushed the chore/duration-parser-from-array branch from 1285f18 to a3c5c90 Compare March 30, 2024 23:45
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.

None yet

2 participants