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

optimize read float

This commit is contained in:
Tao Wen
2016-12-08 10:02:18 +08:00
parent 44a65aa13a
commit ec19f6de6a
2 changed files with 44 additions and 19 deletions

View File

@ -3,6 +3,7 @@ package jsoniter
import (
"testing"
"encoding/json"
"fmt"
)
func Test_float64_0(t *testing.T) {
@ -25,13 +26,15 @@ func Test_float32_1_dot_1_comma(t *testing.T) {
iter := ParseString(`1.1,`)
val := iter.ReadFloat32()
if val != 1.1 {
fmt.Println(iter.Error)
t.Fatal(val)
}
}
func Benchmark_jsoniter_float(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
iter := ParseString(`1.1`)
iter := ParseString(`1.1111111111`)
iter.ReadFloat64()
}
}