dustin/go-humanize: −40.2% ns/op in a measured run
CAVEATED
upstream PR open, not yet reviewed · its first commit was slower on NaN and ±Inf
HEADLINE
−40.2% ns/op
geomean over the declared benchmarks
before → after
bar length is relative to the before valueCommaf ns/op−51.4%
Bytes ns/op−69.8%
what changed
Commaf used strings.Split to find the decimal point. It now uses strings.IndexByte and one pre-sized []byte. humanateBytes called fmt.Sprintf to build a format string, then called it again. It now uses strconv.AppendFloat. BigBytes (129.1 → 134.6 ns/op) and Commas (17.31 → 18.31 ns/op) did not improve. The run document reads both as noise.
6 experiments
3
kept
2
discarded
1
crashed
note — one of the three keeps was spurious: a re-measure that changed no code, kept by a flawed keep rule that is now fixed. The first upstream commit of this change was 30% slower on NaN and ±Inf. A second commit, found by hand, removed that slowdown.
how it was measured
- tool
go test -bench- rounds
- 10 interleaved rounds per side
- verdict rule
- v0.1.0: KEEP if the score was below 1 and one benchmark improved significantly. This rule was flawed. It is now stricter.
LIMITS
Results hold only for the benchmarks a run measures. Inputs they do not cover can get slower. Check your hot paths before you merge.