refactor: use b.Loop() to simplify the code
Overview
replace for i := range b.N or for range b.N in a benchmark with for b.Loop(), and remove any preceding calls to b.StopTimer, b.StartTimer, and b.ResetTimer.
Supported by Go Team, more info: https://go.dev/blog/testing-b-loop
For simple benchmarks where the entire loop body should be timed, the traditional for i := 0; i < b.N; i++ loop is still the correct and idiomatic approach. Changing them to for b.Loop() { ... } without adding b.StartTimer() causes the benchmark to measure nothing, effectively breaking it.
Gemini code assist seems incorrect based on the article: https://go.dev/blog/testing-b-loop#when-to-use
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 83.03%. Comparing base (d6c118c) to head (e736b47).
:warning: Report is 53 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #380 +/- ##
==========================================
+ Coverage 80.89% 83.03% +2.13%
==========================================
Files 8 7 -1
Lines 869 831 -38
==========================================
- Hits 703 690 -13
+ Misses 119 102 -17
+ Partials 47 39 -8
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.