-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON benchmark #3
Comments
Actually I don't full understand your question. What is x, y, z? You mean that coordinate struct that has 3 float in it?. And second my benchmark test-cases are not the same test-cases with this repository so a comparison between them ( at least only with numbers ) is wrong. Because they are not tested with same data. If you want a fully compare two of them you have to create a benchmark with same data. Don't worry if systems are similar then I benchmark them and let you now :) Note: this benchmark results in seconds, my results in nano second. |
This is my test case without calculation comparing to Jsoniter version in that benchmark.
|
Okay. I going to analyze it thanks for your respond. |
No problem, this has also been merge a while ago, it consume less memory For another reference: |
Yes I have finally finish to analyze and found some noticeable things. First in this test file https://github.com/kostya/benchmarks/blob/master/json/test_jsoniter.go it is not a raw byte parsing it uses this 'Decode' function. It is pretty much similar to Second It really consumes 465.90 MB of memory for 106.3 MB test-case data, in my benchmark. Here is my benchmark results for your test-case '1.json' JsoniteratorParse 2 864534010 ns/op 190838500 B/op 4182647 allocs/op
JinParseParse 2 827878780 ns/op 488532972 B/op 9961426 allocs/op In parsing with Jin is slightly faster but it consumes much more memory (468.90 MB) than jsoniter. JsoniteratorGet 1 4697474480 ns/op 882330784 B/op 23004635 allocs/op
JinParseGet 2 824512052 ns/op 488532376 B/op 9961423 allocs/op In Benchmark of Parse() + Get() function I parse the data and try to access 0. 262,144. and 524,287. element of "coordinates" keyword. (Basically first, middle and last values.) Jin is still consuming 465.90 MB of memory but jsoninter now consumes 841.46 MB. that is huge. And respond time is 4.7 seconds. Jin response time is 0.82 seconds it is 5.7 times faster. here is the benchmark file. package kostyaBench
import (
"github.com/ecoshub/penman"
"github.com/ecoshub/jin"
"github.com/json-iterator/go"
"testing"
)
var json []byte = penman.Read("/tmp/1.json")
func BenchmarkJsoniteratorParse(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
prs := jsoniter.Get(json)
nop(prs)
}
}
func BenchmarkJinParseParse(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
prs, _ := jin.Parse(json)
nop(prs)
}
}
func BenchmarkJsoniteratorGet(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
prs := jsoniter.Get(json)
prs.Get("coordinates", 0)
prs.Get("coordinates", 262144)
prs.Get("coordinates", 524287)
}
}
func BenchmarkJinParseGet(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
prs, _ := jin.Parse(json)
prs.Get("coordinates", "0")
prs.Get("coordinates", "262144")
prs.Get("coordinates", "524287")
}
}
func nop(_ ...interface{}) {} |
Thanks for the guidance and It's awesome to read how both fare, probably I have opposite result on macOS Catalina, I hope it's useful for your reference and will be keen to further test. Jsoniter parser using unmarshal with Penman ran a full benchmark and completed in 1.15s. |
In JSON benchmark, which use 1.json sample, which is the best practice to parser/interpret x, y, z?
https://github.com/kostya/benchmarks
Jsoniter is faster than Jin on parser in this case.
The text was updated successfully, but these errors were encountered: