-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb_test.go
62 lines (56 loc) · 1.43 KB
/
db_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
package opao_test
import (
"testing"
"github.com/OblivionOcean/opao"
"github.com/OblivionOcean/opao/support"
"github.com/OblivionOcean/opao/support/mysql"
_ "github.com/go-sql-driver/mysql"
)
//go test -benchmem -bench=^Benchmark -cpuprofile=cpu.pprof -memprofile=mem.pprof
func TestMysql(t *testing.T) {
opao.NewDatabase("mysql", "root:123456@tcp(127.0.0.1:3306)/test?charset=utf8mb4&parseTime=True&loc=Local")
}
/*
func BenchmarkRegObj(t *testing.B) {
// 测试Obj注册
type TestObj struct {
Id int `db:"id`
Name string `db:"name"`
UserAge int `db:"user_age"`
my int `db:"my"`
}
orm := &support.ORM{}
orm.Init(nil, nil)
for i := 0; i < t.N; i++ {
orm.Register("test", &TestObj{})
}
}
func BenchmarkLoadObj(t *testing.B) {
type TestObj struct {
Id int `db:"id`
Name string `db:"name"`
UserAge int `db:"user_age"`
my int `db:"my"`
}
orm := &support.ORM{}
orm.Init(nil, mysql.NewMySQL)
orm.Register("test", &TestObj{})
for i := 0; i < t.N; i++ {
orm.Load("test")
}
}*/
func BenchmarkUpdate(t *testing.B) {
type TestObj struct {
Id int `db:"id"`
Name string `db:"name"`
UserAge int `db:"user_age"`
my int `db:"my"`
}
orm := &support.ORM{}
orm.Init(nil, mysql.NewMySQL)
orm.Register("test", &TestObj{})
obj := orm.Load(&TestObj{})
for i := 0; i < t.N; i++ {
obj.Create()
}
}