-
-
Notifications
You must be signed in to change notification settings - Fork 238
/
bench_test.go
45 lines (39 loc) · 854 Bytes
/
bench_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package null
import (
"testing"
)
func BenchmarkIntUnmarshalJSON(b *testing.B) {
input := []byte("123456")
var nullable Int
for n := 0; n < b.N; n++ {
nullable.UnmarshalJSON(input)
}
}
func BenchmarkIntStringUnmarshalJSON(b *testing.B) {
input := []byte(`"123456"`)
var nullable String
for n := 0; n < b.N; n++ {
nullable.UnmarshalJSON(input)
}
}
func BenchmarkNullIntUnmarshalJSON(b *testing.B) {
input := []byte("null")
var nullable Int
for n := 0; n < b.N; n++ {
nullable.UnmarshalJSON(input)
}
}
func BenchmarkStringUnmarshalJSON(b *testing.B) {
input := []byte(`"hello"`)
var nullable String
for n := 0; n < b.N; n++ {
nullable.UnmarshalJSON(input)
}
}
func BenchmarkNullStringUnmarshalJSON(b *testing.B) {
input := []byte("null")
var nullable String
for n := 0; n < b.N; n++ {
nullable.UnmarshalJSON(input)
}
}