1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-18 22:57:33 +02:00

optimize read string

This commit is contained in:
Tao Wen
2017-01-16 23:43:20 +08:00
parent b9e3f01bfd
commit e7ff7339b2
3 changed files with 221 additions and 185 deletions

View File

@ -7,6 +7,12 @@ import (
"github.com/json-iterator/go/require"
)
func Test_read_large_string(t *testing.T) {
should := require.New(t)
iter := ParseString(`"0123456789012345678901234567890123456789"`)
should.Equal("0123456789012345678901234567890123456789", iter.ReadString())
}
func Test_decode_string_empty(t *testing.T) {
iter := Parse(bytes.NewBufferString(`""`), 4096)
val := iter.ReadString()
@ -113,10 +119,11 @@ func Benchmark_jsoniter_unicode(b *testing.B) {
}
func Benchmark_jsoniter_ascii(b *testing.B) {
iter := ParseString(`"hello, world!"`)
iter := NewIterator()
input := []byte(`"hello, world! hello, world!"`)
b.ResetTimer()
for n := 0; n < b.N; n++ {
iter.ResetBytes(iter.buf)
iter.ResetBytes(input)
iter.ReadString()
}
}