forked from volatiletech/boilbench
-
Notifications
You must be signed in to change notification settings - Fork 1
/
raw_bind_test.go
127 lines (109 loc) · 2.27 KB
/
raw_bind_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
package main
import (
"database/sql"
"testing"
"github.com/go-xorm/xorm"
"github.com/jinzhu/gorm"
"github.com/jmoiron/sqlx"
"github.com/vattle/boilbench/gorms"
"github.com/vattle/boilbench/gorps"
"github.com/vattle/boilbench/mimic"
"github.com/vattle/boilbench/models"
"github.com/vattle/boilbench/xorms"
"github.com/vattle/sqlboiler/boil"
"gopkg.in/gorp.v1"
)
func BenchmarkGORMRawBind(b *testing.B) {
query := jetQuery()
mimic.NewQuery(query)
gormdb, err := gorm.Open("mimic", "")
if err != nil {
panic(err)
}
b.Run("gorm", func(b *testing.B) {
for i := 0; i < b.N; i++ {
var store []gorms.Jet
err := gormdb.Raw("select * from jets").Scan(&store).Error
if err != nil {
b.Fatal(err)
}
store = nil
}
})
}
func BenchmarkGORPRawBind(b *testing.B) {
query := jetQuery()
mimic.NewQuery(query)
db, err := sql.Open("mimic", "")
if err != nil {
panic(err)
}
gorpdb := &gorp.DbMap{Db: db, Dialect: gorp.PostgresDialect{}}
if err != nil {
panic(err)
}
b.Run("gorp", func(b *testing.B) {
for i := 0; i < b.N; i++ {
var store []gorps.Jet
_, err = gorpdb.Select(&store, "select * from jets")
if err != nil {
b.Fatal(err)
}
store = nil
}
})
}
func BenchmarkXORMRawBind(b *testing.B) {
query := jetQuery()
mimic.NewQuery(query)
xormdb, err := xorm.NewEngine("mimic", "")
if err != nil {
panic(err)
}
b.Run("xorm", func(b *testing.B) {
for i := 0; i < b.N; i++ {
var store []xorms.Jet
err = xormdb.SQL("select * from jets").Find(&store)
if err != nil {
b.Fatal(err)
}
store = nil
}
})
}
func BenchmarkSQLXRawBind(b *testing.B) {
query := jetQuery()
mimic.NewQuery(query)
db, err := sqlx.Open("mimic", "")
if err != nil {
panic(err)
}
b.Run("sqlx", func(b *testing.B) {
for i := 0; i < b.N; i++ {
var slice []models.Jet
err = db.Select(&slice, "select * from jets")
if err != nil {
b.Fatal(err)
}
slice = nil
}
})
}
func BenchmarkBoilRawBind(b *testing.B) {
query := jetQuery()
mimic.NewQuery(query)
db, err := sql.Open("mimic", "")
if err != nil {
panic(err)
}
b.Run("boil", func(b *testing.B) {
for i := 0; i < b.N; i++ {
var slice []models.Jet
boil.SQL(db, "select * from jets").Bind(&slice)
if err != nil {
b.Fatal(err)
}
slice = nil
}
})
}