Open
Description
Hello! First of all, thank you for your work on the project. I was curious about go-jsonstream jwriter and I've run your benchmarks, but the results seem to be unexpected.
I was running benchmarks from latest commit (at the moment of Feb 23 2025) in v3 branch, id = 3700efa
go version go1.23.4 linux/amd64
goos: linux
goarch: amd64
pkg: github.com/launchdarkly/go-jsonstream/v3/jwriter
cpu: Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz
BenchmarkJSONMarshalComparatives/Null-16 11927364 93.33 ns/op
BenchmarkJSONMarshalComparatives/Boolean-16 7932656 152.1 ns/op
BenchmarkJSONMarshalComparatives/NumberInt-16 6426847 173.8 ns/op
BenchmarkJSONMarshalComparatives/NumberFloat-16 4020000 295.5 ns/op
BenchmarkJSONMarshalComparatives/String-16 4988412 241.7 ns/op
BenchmarkJSONMarshalComparatives/ArrayOfBools-16 489166 2291 ns/op
BenchmarkJSONMarshalComparatives/ArrayOfStrings-16 151531 8041 ns/op
BenchmarkJSONMarshalComparatives/Object-16 2539591 463.7 ns/op
BenchmarkWriteNull-16 13551864 109.7 ns/op
BenchmarkWriteBoolean-16 10876502 120.3 ns/op
BenchmarkWriteNumberInt-16 7821781 142.8 ns/op
BenchmarkWriteNumberFloat-16 4892714 242.4 ns/op
BenchmarkWriteString-16 10094972 121.9 ns/op
BenchmarkWriteArrayOfBools-16 334783 4070 ns/op
BenchmarkWriteArrayOfStrings-16 73909 16104 ns/op
BenchmarkWriteObject-16 3384001 351.4 ns/op
BenchmarkWriteObjectToNoOpWriterNoAllocs-16 61757113 19.59 ns/op
BenchmarkStreamingWriterArrayOfStrings-16 79692 18884 ns/op
I expected streaming writer to vastly outperform encoding/json package, but it is not the case, in some cases it is significantly slower even than encoding/json.
Is it expected?
Metadata
Metadata
Assignees
Labels
No labels