Last active
March 10, 2026 20:44
-
-
Save aaron-prindle/aa2fda76e5167a42a604906f9cdf7db5 to your computer and use it in GitHub Desktop.
pr_137581_bench_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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