Rodrigo Schio
rschio.bsky.social
Rodrigo Schio
@rschio.bsky.social
It's returning a sub nanosecond result. I think it's a dead-code elimination.
My thought was the same as yours, that using the sink would avoid this, but the result below 1ns makes me think the opposite.

My setup:
goos: darwin
goarch: arm64
pkg: sdfs/headers
cpu: Apple M3 Pro
May 1, 2025 at 12:50 AM
Very interesting and unintuitive ways to optimize! Like why naked returns helps?

One minor thing: the old benchmark loop range is optimizing the benchmark, using the new `b.Loop()` fixes it.

old:
BenchmarkTrimOWS/empty-11 ... 0.9915 ns/op
new:
BenchmarkTrimOWS/empty-11 ... 1.352 ns/op
May 1, 2025 at 12:14 AM
Iterators are fantastic, I mostly used pushes, but I needed Pull2 to implement Tarjan's non-recursive Strong Connected Components and they worked great: github.com/rschio/grafo...
grafo/strong.go at main · rschio/grafo
Graph Theory package. Contribute to rschio/grafo development by creating an account on GitHub.
github.com
April 2, 2025 at 1:45 AM