Closed nolouch closed 6 months ago
In our scenario, the Len function may frequently invoked.
before:
go test -benchmem -run=^$ -bench ^BenchmarkUnbounded github.com/smallnest/chanx goos: darwin goarch: arm64 pkg: github.com/smallnest/chanx BenchmarkUnboundedChanLen-12 65669220 18.17 ns/op 32 B/op 1 allocs/op BenchmarkUnboundedBufLen-12 69060109 18.27 ns/op 32 B/op 1 allocs/op
after
goos: darwin goarch: arm64 pkg: github.com/smallnest/chanx BenchmarkUnboundedChanLen-12 1000000000 0.2879 ns/op 0 B/op 0 allocs/op BenchmarkUnboundedBufLen-12 1000000000 0.2846 ns/op 0 B/op 0 allocs/op
PTAL @smallnest
In our scenario, the Len function may frequently invoked.
before:
after