-
-
Notifications
You must be signed in to change notification settings - Fork 221
/
Copy pathsql_test.go
115 lines (101 loc) · 2.36 KB
/
sql_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
package types
import (
"testing"
"github.com/dolthub/vitess/go/sqltypes"
"github.com/shopspring/decimal"
"github.com/dolthub/go-mysql-server/sql"
)
var result_ sqltypes.Value
func BenchmarkNumI64SQL(b *testing.B) {
var res sqltypes.Value
t := Int64
ctx := sql.NewEmptyContext()
for i := 0; i < b.N; i++ {
res, _ = t.SQL(ctx, nil, i)
}
result_ = res
}
func BenchmarkVarchar10SQL(b *testing.B) {
var res sqltypes.Value
t := MustCreateStringWithDefaults(sqltypes.VarChar, 10)
buf := sql.NewByteBuffer(1000)
ctx := sql.NewEmptyContext()
for i := 0; i < b.N; i++ {
res, _ = t.SQL(ctx, buf.Get(), "char")
buf.Grow(res.Len())
buf.Reset()
}
result_ = res
}
func BenchmarkTimespanSQL(b *testing.B) {
var res sqltypes.Value
t := TimespanType_{}
ctx := sql.NewEmptyContext()
for i := 0; i < b.N; i++ {
res, _ = t.SQL(ctx, nil, i%60)
}
result_ = res
}
func BenchmarkTimestampSQL(b *testing.B) {
var res sqltypes.Value
t := Timestamp
ctx := sql.NewEmptyContext()
for i := 0; i < b.N; i++ {
res, _ = t.SQL(ctx, nil, "2019-12-31T12:00:00Z")
}
result_ = res
}
func BenchmarkDatetimeSQL(b *testing.B) {
var res sqltypes.Value
t := Datetime
ctx := sql.NewEmptyContext()
for i := 0; i < b.N; i++ {
res, _ = t.SQL(ctx, nil, "2019-12-31T12:00:00Z")
}
result_ = res
}
func BenchmarkEnumSQL(b *testing.B) {
var res sqltypes.Value
t, _ := CreateEnumType([]string{"a", "b", "c"}, sql.Collation_Default)
ctx := sql.NewEmptyContext()
for i := 0; i < b.N; i++ {
res, _ = t.SQL(ctx, nil, "a")
}
result_ = res
}
func BenchmarkSetSQL(b *testing.B) {
var res sqltypes.Value
t, _ := CreateSetType([]string{"a", "b", "c"}, sql.Collation_Default)
ctx := sql.NewEmptyContext()
for i := 0; i < b.N; i++ {
res, _ = t.SQL(ctx, nil, "a")
}
result_ = res
}
func BenchmarkBitSQL(b *testing.B) {
var res sqltypes.Value
t := BitType_{numOfBits: 8}
ctx := sql.NewEmptyContext()
for i := 0; i < b.N; i++ {
res, _ = t.SQL(ctx, nil, i%8)
}
result_ = res
}
func BenchmarkDecimalSQL(b *testing.B) {
var res sqltypes.Value
t, _ := CreateColumnDecimalType(2, 2)
ctx := sql.NewEmptyContext()
for i := 0; i < b.N; i++ {
res, _ = t.SQL(ctx, nil, decimal.New(int64(i), 2))
}
result_ = res
}
func BenchmarkNumF64SQL(b *testing.B) {
var res sqltypes.Value
t := Float64
ctx := sql.NewEmptyContext()
for i := 0; i < b.N; i++ {
res, _ = t.SQL(ctx, nil, i)
}
result_ = res
}