测试
This commit is contained in:
parent
f885b5c8f0
commit
2a68b73773
|
@ -101,6 +101,7 @@ func (p post) Table() string {
|
|||
var ctx = context.Background()
|
||||
|
||||
var glob *SqlxQuery
|
||||
var ddb *sqlx.DB
|
||||
|
||||
func init() {
|
||||
db, err := sqlx.Open("mysql", "root:root@tcp(192.168.66.47:3306)/wordpress?charset=utf8mb4&parseTime=True&loc=Local")
|
||||
|
@ -108,6 +109,7 @@ func init() {
|
|||
panic(err)
|
||||
}
|
||||
glob = NewSqlxQuery(db, NewUniversalDb(nil, nil))
|
||||
ddb = db
|
||||
InitDB(glob)
|
||||
}
|
||||
func TestFind(t *testing.T) {
|
||||
|
|
|
@ -507,10 +507,21 @@ func Test_findScanner(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func BenchmarkSqlxQueryXX(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
var r []options
|
||||
err := ddb.Select(&r, "select * from wp_options where option_id<100")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkScannerXX(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
var r []options
|
||||
err := findScanner[options](glob, ctx, func(t options) {
|
||||
_ = t
|
||||
r = append(r, t)
|
||||
//fmt.Println(t)
|
||||
}, Conditions(Where(SqlBuilder{{"option_id", "<", "100", "int"}})))
|
||||
if err != nil {
|
||||
|
@ -521,14 +532,10 @@ func BenchmarkScannerXX(b *testing.B) {
|
|||
|
||||
func BenchmarkFindsXX(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
r, err := finds[options](glob, ctx, Conditions(Where(SqlBuilder{{"option_id", "<", "100", "int"}})))
|
||||
_, err := finds[options](glob, ctx, Conditions(Where(SqlBuilder{{"option_id", "<", "100", "int"}})))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for _, o := range r {
|
||||
_ = o
|
||||
//fmt.Println(o)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user