-
Notifications
You must be signed in to change notification settings - Fork 221
/
Copy pathrecord_reader_benchmark_test.go
71 lines (60 loc) · 1.65 KB
/
record_reader_benchmark_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
package input
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/johnkerl/miller/v6/pkg/cli"
)
// go test -run=nonesuch -bench=. github.com/johnkerl/miller/v6/pkg/input/...
func BenchmarkDKVPParse(b *testing.B) {
readerOptions := &cli.TReaderOptions{
InputFileFormat: "dkvp",
IFS: ",",
IPS: "=",
IRS: "\n",
}
reader, err := NewRecordReaderDKVP(readerOptions, 1)
assert.Nil(b, err)
for i := 0; i < b.N; i++ {
_, _ = recordFromDKVPLine(
reader,
"color=yellow,shape=triangle,flag=true,k=1,index=11,quantity=43.6498,rate=9.8870",
)
}
}
func BenchmarkNIDXParse(b *testing.B) {
readerOptions := &cli.TReaderOptions{
InputFileFormat: "nidx",
IFS: " ",
AllowRepeatIFS: true,
IRS: "\n",
}
reader, err := NewRecordReaderNIDX(readerOptions, 1)
assert.Nil(b, err)
for i := 0; i < b.N; i++ {
_, _ = recordFromDKVPLine(
reader,
"yellow triangle true 1 11 43.6498 9.8870",
)
}
}
func BenchmarkXTABParse(b *testing.B) {
readerOptions := &cli.TReaderOptions{
InputFileFormat: "xtab",
IPS: " ",
IFS: "\n",
IRS: "\n",
}
reader, err := NewRecordReaderXTAB(readerOptions, 1)
assert.Nil(b, err)
stanza := newStanza()
stanza.dataLines.PushBack("color yellow")
stanza.dataLines.PushBack("shape triangle")
stanza.dataLines.PushBack("flag true")
stanza.dataLines.PushBack("k 1")
stanza.dataLines.PushBack("index 11")
stanza.dataLines.PushBack("quantity 43.6498")
stanza.dataLines.PushBack("rate 9.8870")
for i := 0; i < b.N; i++ {
_, _ = reader.recordFromXTABLines(stanza.dataLines)
}
}