Last active
April 18, 2016 16:34
-
-
Save dtjm/d232bf2ddb56d9e1349ca627450dba02 to your computer and use it in GitHub Desktop.
Revisions
-
Sam Nguyen revised this gist
Apr 18, 2016 . 2 changed files with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -23,8 +23,8 @@ func BenchmarkMapBytesKey(b *testing.B) { func BenchmarkMapBytesConvertKey(b *testing.B) { var m map[string]string = make(map[string]string) var k []byte = []byte("key") for i := 0; i < b.N; i++ { var ks = string(k) _, _ = m[ks] } } 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ $ go test -bench=. -benchmem map_test.go testing: warning: no tests to run PASS BenchmarkMapStringKey-4 300000000 4.57 ns/op 0 B/op 0 allocs/op BenchmarkMapBytesKey-4 200000000 7.00 ns/op 0 B/op 0 allocs/op BenchmarkMapBytesConvertKey-4 100000000 20.8 ns/op 0 B/op 0 allocs/op ok command-line-arguments 13.046s -
Sam Nguyen revised this gist
Apr 18, 2016 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ $ go test -bench=. -benchmem map_test.go testing: warning: no tests to run PASS BenchmarkMapStringKey-4 300000000 4.88 ns/op 0 B/op 0 allocs/op BenchmarkMapBytesKey-4 200000000 7.00 ns/op 0 B/op 0 allocs/op BenchmarkMapBytesConvertKey-4 300000000 4.59 ns/op 0 B/op 0 allocs/op ok command-line-arguments 9.924s -
Sam Nguyen created this gist
Apr 18, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ package map_test import ( "testing" ) func BenchmarkMapStringKey(b *testing.B) { var m map[string]string = make(map[string]string) var k string = "key" for i := 0; i < b.N; i++ { _, _ = m[k] } } func BenchmarkMapBytesKey(b *testing.B) { var m map[string]string = make(map[string]string) var k []byte = []byte("key") for i := 0; i < b.N; i++ { _, _ = m[string(k)] } } func BenchmarkMapBytesConvertKey(b *testing.B) { var m map[string]string = make(map[string]string) var k []byte = []byte("key") var ks = string(k) for i := 0; i < b.N; i++ { _, _ = m[ks] } }