Created
January 29, 2020 11:32
-
-
Save powerman/9919c143569bc08181bb2ae6b90ff1e7 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
func BenchmarkJSON(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
obj := Object{} | |
if err := json.Unmarshal(testCase, &obj); err != nil { | |
b.Fatal(err) | |
} | |
} | |
} | |
func BenchmarkFastJSON(b *testing.B) { | |
var p fastjson.Parser | |
for i := 0; i < b.N; i++ { | |
obj := Object{} | |
v, err := p.ParseBytes(testCase) | |
if err != nil { | |
b.Fatal(err) | |
} | |
obj.A, err = uuid.ParseBytes(v.GetStringBytes("A")) | |
if err != nil { | |
b.Fatal(err) | |
} | |
obj.B = v.GetFloat64("B") | |
obj.C = string(v.GetStringBytes("C")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment