diff --git a/model/query_test.go b/model/query_test.go index a47482a..ee38a57 100644 --- a/model/query_test.go +++ b/model/query_test.go @@ -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) { diff --git a/model/querycondition_test.go b/model/querycondition_test.go index 142118f..93ef718 100644 --- a/model/querycondition_test.go +++ b/model/querycondition_test.go @@ -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) - } } }