Four of five loops had no bounds check to remove
The compiler eliminated every check in four spellings of the same sum. The folklore hint changed nothing, and the one surviving check cost less than the harness's own error.
Benchmarking method, profiling, allocation, escape analysis and compiler behaviour — the subject where the evidence standard is most visible.
The compiler eliminated every check in four spellings of the same sum. The folklore hint changed nothing, and the one surviving check cost less than the harness's own error.
The compiler prints what every construct costs. A make and a map index cost 2 each; a call costs 59; defer and go are not priced at all — they disqualify.
`-gcflags=-m` printed "escapes to heap" for the constructor and "does not escape" for half the places that call it. The package boundary had nothing to do with it.
Same program, two sample types. alloc_space blames my function for 100% of it; inuse_space blames the runtime's scavenger, and both are correct.
Go 1.27's size-specialised allocation is worth up to 46% on the pointer-containing path, not the 30% announced — and from 96 bytes up it is worth nothing.
Two sub-benchmarks calling the same function with the same argument came back 1.10% apart at p=0.000. What a benchmark measures is not only your code.
The compiler said "does not escape" and the benchmark reported 104 KiB per operation. Both were right. What -gcflags=-m actually tells you.