Untitled

Run Settings
LanguageGo
Language Version
Run Command
package test import ( "testing" "strconv" ) // BenchmarkStrKey-8 50000000 39.1 ns/op 0 B/op 0 allocs/op func BenchmarkStrKey(b *testing.B) { data := map[string]struct{}{} for i := 0; i < 1000000; i++ { data[strconv.Itoa(i)] = struct{}{} } b.ResetTimer() for i := 0; i < b.N; i++ { _ = data["31232"] // Existed. _ = data["31232231231231"] // Non-existed. } } type Key struct { x int y int } // BenchmarkStructKey-8 30000000 52.2 ns/op 0 B/op 0 allocs/op func BenchmarkStructKey(b *testing.B) { data := map[Key]struct{}{} for i := 0; i < 1000000; i++ { data[Key{i, 1000000 - i}] = struct{}{} } b.ResetTimer() for i := 0; i < b.N; i++ { _ = data[Key{123123, 213312}] // Existed. _ = data[Key{123123, 21331223123}] // Non-existed. } }
Editor Settings
Theme
Key bindings
Full width
Lines