Created
July 6, 2016 10:02
-
-
Save kaneshin/9afe28017f9cdbb1e1bad141519414c3 to your computer and use it in GitHub Desktop.
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
var jsonData = []byte(`{"foo":true,"bar":1,"hoge":"hogehoge"}`) | |
var data map[string]interface{} | |
func BenchmarkUnmarshal(b *testing.B) { | |
for n := 0; n < b.N; n++ { | |
json.Unmarshal(jsonData, &data) | |
} | |
} | |
var buf bytes.Buffer | |
func init() { | |
buf.Write([]byte(`{"foo":true,"bar":1,"hoge":"hogehoge"}`)) | |
} | |
func BenchmarkDecoder(b *testing.B) { | |
for n := 0; n < b.N; n++ { | |
json.NewDecoder(&buf).Decode(&data) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.