Skip to content

Commit

Permalink
Added benchmarks of using codepoint indices
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Gaynor committed Jun 28, 2019
1 parent 4fa3b01 commit 99dc89b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ func BenchmarkUnmarshal_MixedData_100000(b *testing.B) {
}
}

func BenchmarkDecode_CodePoints_MixedData_1_Ascii(b *testing.B) {
data := []byte(` foo foo 42 42 42 42 42 42 42 42 4.2 4.2 4.2 4.2`)
var v mixedData
for i := 0; i < b.N; i++ {
d := NewDecoder(bytes.NewReader(data))
d.SetUseCodepointIndices(true)
_ = d.Decode(&v)
}
}

func BenchmarkDecode_CodePoints_MixedData_1_UTF8(b *testing.B) {
data := []byte(` f☃☃ f☃☃ 42 42 42 42 42 42 42 42 4.2 4.2 4.2 4.2`)
var v mixedData
for i := 0; i < b.N; i++ {
d := NewDecoder(bytes.NewReader(data))
d.SetUseCodepointIndices(true)
_ = d.Decode(&v)
}
}

func BenchmarkUnmarshal_String(b *testing.B) {
data := []byte(`foo `)
var v struct {
Expand Down

0 comments on commit 99dc89b

Please sign in to comment.