Skip to content

Commit

Permalink
Use json.Valid instead of unmarshaling into an empty struct in Valida…
Browse files Browse the repository at this point in the history
…te/stdjson benchmark
  • Loading branch information
valyala committed Jun 9, 2018
1 parent 66c764c commit 76c16f5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions validate_timing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ func benchmarkValidateStdJSON(b *testing.B, s string) {
b.SetBytes(int64(len(s)))
bb := s2b(s)
b.RunParallel(func(pb *testing.PB) {
var m struct{}
for pb.Next() {
if err := json.Unmarshal(bb, &m); err != nil {
panic(fmt.Errorf("unexpected error: %s", err))
if !json.Valid(bb) {
panic("json.Valid unexpectedly returned false")
}
}
})
Expand Down

0 comments on commit 76c16f5

Please sign in to comment.