Also consider *json.RawMessage
- Ngôn ngữ chính
- Go
- Star
- 599
- Fork
- 15
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
You may want to include `map[string]*json.RawMessage` in your benchmarks.
That is on par with djson for the medium sample and faster for the large sample. json.RawMessage is the recommended solution for partial json parsing with the standard library and enough if all you want to do is add or remove fields from a document.
``` go
func BenchmarkEncodingJsonParser_RawMessage(b *testing.B) {
b.Run("small", func(b *testing.B) {
for i := 0; i < b.N; i++ {
data := make(map[string]*json.RawMessage)
json.Unmarshal(smallFixture, &data)
}
})
b.Run("medium", func(b *testing.B) {
for i := 0; i < b.N; i++ {
data := make(map[string]*json.RawMessage)
json.Unmarshal(mediumFixture, &data)
}
})
b.Run("large", func(b *testing.B) {
for i := 0; i < b.N; i++ {
data := make(map[string]*json.RawMessage)
json.Unmarshal(largeFixture, &data)
}
})
}
```
```
# Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz
BenchmarkEncodingJsonParser/small-8 200000 11520 ns/op
BenchmarkEncodingJsonParser/medium-8 30000 48620 ns/op
BenchmarkEncodingJsonParser/large-8 2000 872325 ns/op
BenchmarkEncodingJsonParser_RawMessage/small-8 100000 10146 ns/op
BenchmarkEncodingJsonParser_RawMessage/medium-8 50000 23538 ns/op
BenchmarkEncodingJsonParser_RawMessage/large-8 3000 340215 ns/op
BenchmarkDJsonParser/small-8 500000 2865 ns/op
BenchmarkDJsonParser/medium-8 50000 25407 ns/op
BenchmarkDJsonParser/large-8 3000 478260 ns/op
BenchmarkDJsonAllocString/small-8 1000000 2520 ns/op
BenchmarkDJsonAllocString/medium-8 100000 21715 ns/op
BenchmarkDJsonAllocString/large-8 5000 422390 ns/op
```
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
The issue suggests adding a benchmark for `map[string]*json.RawMessage` to compare performance. Look at the existing benchmark file (likely `benchmark_test.go` or similar) to see how benchmarks are structured. Add the provided function, ensuring it uses the same fixtures. Run `go test -bench=.` to verify the new benchmark works and compare results.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- go, json
- Lĩnh vực
- performance, testing-qa
- Loại issue
- Tính năng
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 70/100