forked from karrick/goavro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark_helpers_test.go
150 lines (137 loc) · 3.66 KB
/
benchmark_helpers_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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package goavro_test
import (
"io/ioutil"
"testing"
)
func benchmarkNewCodecUsingV4(b *testing.B, avscPath string) {
schema, err := ioutil.ReadFile(avscPath)
if err != nil {
b.Fatal(err)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = newCodecUsingV4(b, string(schema))
}
}
func benchmarkNewCodecUsingV5(b *testing.B, avscPath string) {
schema, err := ioutil.ReadFile(avscPath)
if err != nil {
b.Fatal(err)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = newCodecUsingV5(b, string(schema))
}
}
func benchmarkNativeFromAvroUsingV4(b *testing.B, avroPath string) {
avroBlob, err := ioutil.ReadFile(avroPath)
if err != nil {
b.Fatal(err)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _ = nativeFromAvroUsingV4(b, avroBlob)
}
}
func benchmarkNativeFromAvroUsingV5(b *testing.B, avroPath string) {
avroBlob, err := ioutil.ReadFile(avroPath)
if err != nil {
b.Fatal(err)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _ = nativeFromAvroUsingV5(b, avroBlob)
}
}
func benchmarkBinaryFromNativeUsingV4(b *testing.B, avroPath string) {
avroBlob, err := ioutil.ReadFile(avroPath)
if err != nil {
b.Fatal(err)
}
nativeData, codec := nativeFromAvroUsingV4(b, avroBlob)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = binaryFromNativeUsingV4(b, codec, nativeData)
}
}
func benchmarkBinaryFromNativeUsingV5(b *testing.B, avroPath string) {
avroBlob, err := ioutil.ReadFile(avroPath)
if err != nil {
b.Fatal(err)
}
nativeData, codec := nativeFromAvroUsingV5(b, avroBlob)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = binaryFromNativeUsingV5(b, codec, nativeData)
}
}
func benchmarkNativeFromBinaryUsingV4(b *testing.B, avroPath string) {
avroBlob, err := ioutil.ReadFile(avroPath)
if err != nil {
b.Fatal(err)
}
nativeData, codec := nativeFromAvroUsingV4(b, avroBlob)
binaryData := binaryFromNativeUsingV4(b, codec, nativeData)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = nativeFromBinaryUsingV4(b, codec, binaryData)
}
}
func benchmarkNativeFromBinaryUsingV5(b *testing.B, avroPath string) {
avroBlob, err := ioutil.ReadFile(avroPath)
if err != nil {
b.Fatal(err)
}
nativeData, codec := nativeFromAvroUsingV5(b, avroBlob)
binaryData := binaryFromNativeUsingV5(b, codec, nativeData)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = nativeFromBinaryUsingV5(b, codec, binaryData)
}
}
func benchmarkTextualFromNativeUsingJSONMarshal(b *testing.B, avroPath string) {
avroBlob, err := ioutil.ReadFile(avroPath)
if err != nil {
b.Fatal(err)
}
nativeData, codec := nativeFromAvroUsingV4(b, avroBlob)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = textFromNativeUsingJSONMarshal(b, codec, nativeData)
}
}
func benchmarkTextualFromNativeUsingV5(b *testing.B, avroPath string) {
avroBlob, err := ioutil.ReadFile(avroPath)
if err != nil {
b.Fatal(err)
}
nativeData, codec := nativeFromAvroUsingV5(b, avroBlob)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = textFromNativeUsingV5(b, codec, nativeData)
}
}
func benchmarkNativeFromTextualUsingJSONUnmarshal(b *testing.B, avroPath string) {
avroBlob, err := ioutil.ReadFile(avroPath)
if err != nil {
b.Fatal(err)
}
nativeData, codec := nativeFromAvroUsingV4(b, avroBlob)
textData := textFromNativeUsingJSONMarshal(b, codec, nativeData)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = nativeFromTextUsingJSONUnmarshal(b, codec, textData)
}
}
func benchmarkNativeFromTextualUsingV5(b *testing.B, avroPath string) {
avroBlob, err := ioutil.ReadFile(avroPath)
if err != nil {
b.Fatal(err)
}
nativeData, codec := nativeFromAvroUsingV5(b, avroBlob)
textData := textFromNativeUsingV5(b, codec, nativeData)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = nativeFromTextUsingV5(b, codec, textData)
}
}