Skip to content

Commit

Permalink
test(bench): add std variant to BenchmarkValid
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado committed Nov 2, 2021
1 parent f1e0922 commit 91cfa36
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,26 @@ func Benchmark_large_file(b *testing.B) {
}

func BenchmarkValid(b *testing.B) {
b.ReportAllocs()
b.SetBytes(int64(len(data)))

for n := 0; n < b.N; n++ {
if !Valid(data) {
b.Fatal("invalid")
b.Run("JX", func(b *testing.B) {
b.ReportAllocs()
b.SetBytes(int64(len(data)))

for n := 0; n < b.N; n++ {
if !Valid(data) {
b.Fatal("invalid")
}
}
}
})
b.Run("Std", func(b *testing.B) {
b.ReportAllocs()
b.SetBytes(int64(len(data)))

for n := 0; n < b.N; n++ {
if !json.Valid(data) {
b.Fatal("invalid")
}
}
})
}

func Benchmark_std_large_file(b *testing.B) {
Expand Down

0 comments on commit 91cfa36

Please sign in to comment.