-
-
Notifications
You must be signed in to change notification settings - Fork 175
Open
Description
Hello,
I'm probably missing something simple here. When I was trying to compare against standard library using the same large fixture:
func BenchmarkDecodeJSON(b *testing.B) {
payload := ... // gojson.benchmark.LargeFixture
for _, decodeLibrary := range []string{"encoding/json", "goccy/go-json"} {
b.Run(decodeLibrary, func(b *testing.B) {
for i := 0; i < b.N; i++ {
// Unmarshal the payload
var v map[string]any
var err error
switch decodeLibrary {
case "encoding/json":
err = json.Unmarshal(payload, &v)
case "goccy/go-json":
err = gojson.Unmarshal(payload, &v)
}
if err != nil {
b.Fatal(err)
}
}
})
}
}
I get:
cpu: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz
BenchmarkDecodeJSON/encoding/json-2 3286 352568 ns/op 209375 B/op 2785 allocs/op
BenchmarkDecodeJSON/goccy/go-json-2 3772 320198 ns/op 249825 B/op 3490 allocs/op
PASS
Is this not the same data used for the benchmarking in the README? I was expecting to a significant difference, especially for the large fixture payload in decoding.
Running them in seperate benchmarks (instead of using
b.Run
) gives the same results.
Thank for your help.
Metadata
Metadata
Assignees
Labels
No labels