Skip to content

Commit

Permalink
[json] add a benchmark to help check new scan for key
Browse files Browse the repository at this point in the history
  • Loading branch information
draxil committed Aug 7, 2022
1 parent ddeab46 commit a374266
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions internal/json/scanner_bench_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package json

import (
"testing"
)

var input = []byte(
`
"alpha" : {
"zeeta" : [1,2,3,4,5,6,7,8,9,10],
"cheese" : "cake",
},
"cheesy" : 1,
"cheese": 4
}
`,
)

func BenchmarkScanForKey(b *testing.B) {
for n := 0; n < b.N; n++ {
s := NewScanState('{')
s.seekFor("cheese")
_, err := s.scan(input, 0, len(input))
if err != nil {
b.Fatal(err)
}
}
}

0 comments on commit a374266

Please sign in to comment.