scanner的性能比sqlx的select好些的样子

This commit is contained in:
xing 2023-02-22 19:12:26 +08:00
parent 1ecfa19fd4
commit 00f788fad5

View File

@ -84,7 +84,6 @@ func BenchmarkSelectXX(b *testing.B) {
}
func BenchmarkScannerXX(b *testing.B) {
for i := 0; i < b.N; i++ {
_, err := scanners[options](anyDb[options](), ctx, Conditions())
if err != nil {
panic(err)
@ -92,6 +91,16 @@ func BenchmarkScannerXX(b *testing.B) {
}
}
func BenchmarkSqlXQueryXX(b *testing.B) {
for i := 0; i < b.N; i++ {
var r []options
err := sq.Select(&r, "select * from wp_options")
if err != nil {
panic(err)
}
}
}
type options struct {
OptionId uint64 `gorm:"column:option_id" db:"option_id" json:"option_id" form:"option_id"`
OptionName string `gorm:"column:option_name" db:"option_name" json:"option_name" form:"option_name"`