Closed 178inaba closed 7 years ago
This PR provides streaming optimization and testing.
defer
Benchmark of parse:
func BenchmarkAtoi(b *testing.B) { s := " 1234567" for i := 0; i < b.N; i++ { i, err := strconv.Atoi(strings.TrimSpace(s)) _ = int64(i) if err != nil { b.Fatal(err) } } } func BenchmarkParseInt(b *testing.B) { s := " 1234567" for i := 0; i < b.N; i++ { _, err := strconv.ParseInt(strings.TrimSpace(s), 10, 64) if err != nil { b.Fatal(err) } } } func BenchmarkUnmarshal(b *testing.B) { s := " 1234567" for i := 0; i < b.N; i++ { var i int64 err := json.Unmarshal([]byte(s), &i) if err != nil { b.Fatal(err) } } }
BenchmarkAtoi-8 30000000 52.6 ns/op BenchmarkParseInt-8 30000000 48.0 ns/op BenchmarkUnmarshal-8 3000000 445 ns/op
Coverage increased (+3.007%) to 84.226% when pulling c88e2df363e5c9bade8322b6020e4cc100b0d208 on 178inaba:streaming into 70b3dbf5488859738d02a5f741072ce0359bb90d on mattn:master.
In addition, we fixed to close the channel using defer on the sender side. The user can terminate processing by simply canceling the context.
:1st_place_medal: great
This PR provides streaming optimization and testing.
defer
.Benchmark of parse: