package hashmap_test import ( "fmt" "testing" "github.com/alphadose/haxmap" "github.com/cornelk/hashmap" ) func BenchmarkGoMap(t *testing.B) { // 1000000 loop // goos: darwin // goarch: amd64 // pkg: test/hashmap // cpu: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz // BenchmarkGoMap // BenchmarkGoMap-8 1000000000 0.5068 ns/op 0 B/op 0 allocs/op // PASS // ok test/hashmap 14.880s // 100000 loop // goos: darwin // goarch: amd64 // pkg: test/hashmap // cpu: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz // BenchmarkGoMap // BenchmarkGoMap-8 1000000000 0.02783 ns/op 0 B/op 0 allocs/op // PASS // ok test/hashmap 0.721s m := map[string]int{} t.StartTimer() for i := 0; i < 100000; i++ { s := fmt.Sprint(i) m[s] = i } t.StopTimer() } func BenchmarkHaxMap(t *testing.B) { // 1000000 loop // goos: darwin // goarch: amd64 // pkg: test/hashmap // cpu: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz // BenchmarkHaxMap // BenchmarkHaxMap-8 1000000000 0.8453 ns/op 0 B/op 0 allocs/op // PASS // ok test/hashmap 65.175s // 100000 loop // goos: darwin // goarch: amd64 // pkg: test/hashmap // cpu: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz // BenchmarkHaxMap // BenchmarkHaxMap-8 1000000000 0.05282 ns/op 0 B/op 0 allocs/op // PASS // ok test/hashmap 1.154s m := haxmap.New[string, int]() t.StartTimer() for i := 0; i < 100000; i++ { s := fmt.Sprint(i) m.Set(s, i) } t.StopTimer() } func BenchmarkHashMap(t *testing.B) { // 1000000 loop Crash // 100000 loop // goos: darwin // goarch: amd64 // pkg: test/hashmap // cpu: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz // BenchmarkHashMap // BenchmarkHashMap-8 1 33365603372 ns/op 11402896 B/op 399822 allocs/op // PASS // ok test/hashmap 33.493s m := hashmap.New[string, int]() t.StartTimer() for i := 0; i < 100000; i++ { s := fmt.Sprint(i) m.Set(s, i) } t.StopTimer() }