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

🚨 Test: improve benchmarks for getOffer #2739

Merged
merged 1 commit into from
Nov 23, 2023

Conversation

nickajacks1
Copy link
Member

Description

Split getOffers benchmarks into individual cases for easier analysis.
This makes explicit two scenarios with allocations:

  1. The Accept contains 3 or more media type parameters: the code uses a stack allocated slice of length 2, so this is expected.
  2. The Accept contains an unknown mime extension (in this case iso-8859-1). I'm not sure if this is expected or not.
Benchmarks
Benchmark_Utils_GetOffer/simple-8               37348665                31.14 ns/op            0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/simple-8               37296252                31.19 ns/op            0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/simple-8               37496180                31.25 ns/op            0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/simple-8               37886322                31.41 ns/op            0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/6_offers-8             14654864                80.64 ns/op            0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/6_offers-8             14888724                80.79 ns/op            0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/6_offers-8             15045030                85.98 ns/op            0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/6_offers-8             14630626                80.58 ns/op            0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/1_parameter-8          12318861                98.65 ns/op            0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/1_parameter-8          12215715                99.23 ns/op            0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/1_parameter-8          11927502               102.7 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/1_parameter-8          12524857                98.15 ns/op            0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/2_parameters-8          7165609               161.8 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/2_parameters-8          7047482               162.1 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/2_parameters-8          7245342               161.5 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/2_parameters-8          7477488               162.5 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/3_parameters-8          3653287               329.7 ns/op           128 B/op          1 allocs/op
Benchmark_Utils_GetOffer/3_parameters-8          3639289               328.2 ns/op           128 B/op          1 allocs/op
Benchmark_Utils_GetOffer/3_parameters-8          3661699               326.4 ns/op           128 B/op          1 allocs/op
Benchmark_Utils_GetOffer/3_parameters-8          3660715               328.0 ns/op           128 B/op          1 allocs/op
Benchmark_Utils_GetOffer/10_parameters-8          972722              1158 ns/op             896 B/op          3 allocs/op
Benchmark_Utils_GetOffer/10_parameters-8          982041              1157 ns/op             896 B/op          3 allocs/op
Benchmark_Utils_GetOffer/10_parameters-8          948860              1153 ns/op             896 B/op          3 allocs/op
Benchmark_Utils_GetOffer/10_parameters-8         1000000              1151 ns/op             896 B/op          3 allocs/op
Benchmark_Utils_GetOffer/6_offers_w/params-8             4526132               267.6 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/6_offers_w/params-8             4521868               262.9 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/6_offers_w/params-8             4501616               282.0 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/6_offers_w/params-8             4294874               267.2 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/mime_extension-8                6349107               201.9 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/mime_extension-8                6271616               188.5 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/mime_extension-8                6190488               193.3 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/mime_extension-8                6397099               205.7 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/mime_extension#01-8             4531942               265.0 ns/op            48 B/op          2 allocs/op
Benchmark_Utils_GetOffer/mime_extension#01-8             4464699               264.2 ns/op            48 B/op          2 allocs/op
Benchmark_Utils_GetOffer/mime_extension#01-8             4533716               263.1 ns/op            48 B/op          2 allocs/op
Benchmark_Utils_GetOffer/mime_extension#01-8             4529667               265.0 ns/op            48 B/op          2 allocs/op
Benchmark_Utils_GetOffer/mime_extension#02-8             2966164               405.5 ns/op            48 B/op          2 allocs/op
Benchmark_Utils_GetOffer/mime_extension#02-8             2920989               406.7 ns/op            48 B/op          2 allocs/op
Benchmark_Utils_GetOffer/mime_extension#02-8             2968666               403.8 ns/op            48 B/op          2 allocs/op
Benchmark_Utils_GetOffer/mime_extension#02-8             2940620               405.1 ns/op            48 B/op          2 allocs/op
Benchmark_Utils_GetOffer/mime_extension#03-8             6550610               184.1 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/mime_extension#03-8             6341877               197.2 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/mime_extension#03-8             6697556               188.6 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/mime_extension#03-8             6748568               192.4 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/web_browser-8                  10075825               124.1 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/web_browser-8                  10330788               111.5 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/web_browser-8                  10692439               117.3 ns/op             0 B/op          0 allocs/op
Benchmark_Utils_GetOffer/web_browser-8                   9933765               124.0 ns/op             0 B/op          0 allocs/op

Type of change

Please delete options that are not relevant.

  • Unit Tests

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I tried to make my code as fast as possible with as few allocations as possible
  • For new code I have written benchmarks so that they can be analyzed and improved

@ReneWerner87 ReneWerner87 added this to the Next v2 Release milestone Nov 23, 2023
@ReneWerner87 ReneWerner87 merged commit 6b9630b into gofiber:master Nov 23, 2023
21 checks passed
@nickajacks1 nickajacks1 deleted the bench-getoffer branch January 6, 2024 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants