Skip to content

Instantly share code, notes, and snippets.

@aaron-prindle
Last active March 10, 2026 20:44
Show Gist options
  • Select an option

  • Save aaron-prindle/aa2fda76e5167a42a604906f9cdf7db5 to your computer and use it in GitHub Desktop.

Select an option

Save aaron-prindle/aa2fda76e5167a42a604906f9cdf7db5 to your computer and use it in GitHub Desktop.
pr_137581_bench_test.go
package main
import (
"bytes"
"strings"
"testing"
"unique"
)
var globalZeroHandle unique.Handle[string]
var sink bool
func BenchmarkZeroHandle_Literal(b *testing.B) {
var h unique.Handle[string]
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
sink = h == (unique.Handle[string]{})
}
}
func BenchmarkZeroHandle_Global(b *testing.B) {
var h unique.Handle[string]
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
sink = h == globalZeroHandle
}
}
var sinkReader int64
func BenchmarkReader_Bytes(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
sinkReader = bytes.NewReader(nil).Size()
}
}
func BenchmarkReader_Strings(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
sinkReader = strings.NewReader("").Size()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment