1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00

support null/true/false

This commit is contained in:
Tao Wen
2016-12-02 11:22:20 +08:00
parent 05a9df4749
commit ce5b193569
6 changed files with 358 additions and 31 deletions

View File

@ -0,0 +1,50 @@
package jsoniter
import (
"testing"
"os"
"encoding/json"
"io/ioutil"
)
func Test_large_file(t *testing.T) {
file, err := os.Open("/tmp/large-file.json")
if err != nil {
t.Fatal(err)
}
iter := Parse(file, 4096)
count := 0
for iter.ReadArray() {
iter.Skip()
count++
}
if count != 11351 {
t.Fatal(count)
}
}
func Benchmark_jsoniter_large_file(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
file, _ := os.Open("/tmp/large-file.json")
iter := Parse(file, 4096)
count := 0
for iter.ReadArray() {
iter.Skip()
count++
}
file.Close()
}
}
func Benchmark_json_large_file(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
file, _ := os.Open("/tmp/large-file.json")
bytes, _ := ioutil.ReadAll(file)
file.Close()
result := []struct{}{}
json.Unmarshal(bytes, &result)
}
}