More tests
This commit is contained in:
parent
12db3eac1f
commit
7171467de1
|
@ -39,7 +39,7 @@ func Benchmark_Zombiezen(b *testing.B) {
|
|||
|
||||
// Queries
|
||||
|
||||
b.Run("Queries", func(b *testing.B) {
|
||||
b.Run("Parallel Queries with Pool", func(b *testing.B) {
|
||||
b.RunParallel(func(p *testing.PB) {
|
||||
for p.Next() {
|
||||
var as, bs, cs string
|
||||
|
@ -58,6 +58,40 @@ func Benchmark_Zombiezen(b *testing.B) {
|
|||
})
|
||||
})
|
||||
|
||||
b.Run("Sequential Queries with Pool", func(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
var as, bs, cs string
|
||||
conn := dbpool.Get(context.Background())
|
||||
_ = sqlitex.Exec(conn, "select a, b, c from test where a = ?;", func(stmt *sqlite.Stmt) error {
|
||||
as = stmt.ColumnText(0)
|
||||
bs = stmt.ColumnText(1)
|
||||
cs = stmt.ColumnText(2)
|
||||
return nil
|
||||
}, strconv.Itoa(rand.Intn(1000)))
|
||||
dbpool.Put(conn)
|
||||
if as == "" || bs == "" || cs == "" {
|
||||
b.FailNow()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
b.Run("Sequential Queries without Pool", func(b *testing.B) {
|
||||
conn := dbpool.Get(context.Background())
|
||||
defer dbpool.Put(conn)
|
||||
for i := 0; i < b.N; i++ {
|
||||
var as, bs, cs string
|
||||
_ = sqlitex.Exec(conn, "select a, b, c from test where a = ?;", func(stmt *sqlite.Stmt) error {
|
||||
as = stmt.ColumnText(0)
|
||||
bs = stmt.ColumnText(1)
|
||||
cs = stmt.ColumnText(2)
|
||||
return nil
|
||||
}, strconv.Itoa(rand.Intn(1000)))
|
||||
if as == "" || bs == "" || cs == "" {
|
||||
b.FailNow()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func Benchmark_Mattn(b *testing.B) {
|
||||
|
@ -82,7 +116,7 @@ func Benchmark_Mattn(b *testing.B) {
|
|||
|
||||
// Queries
|
||||
|
||||
b.Run("Queries", func(b *testing.B) {
|
||||
b.Run("Parallel Queries", func(b *testing.B) {
|
||||
b.RunParallel(func(p *testing.PB) {
|
||||
for p.Next() {
|
||||
var as, bs, cs string
|
||||
|
@ -97,4 +131,17 @@ func Benchmark_Mattn(b *testing.B) {
|
|||
})
|
||||
})
|
||||
|
||||
b.Run("Sequential Queries", func(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
var as, bs, cs string
|
||||
rows, _ := db.Query("select a, b, c from test where a = ?;", strconv.Itoa(rand.Intn(1000)))
|
||||
for rows.Next() {
|
||||
rows.Scan(&as, &bs, &cs)
|
||||
}
|
||||
if as == "" || bs == "" || cs == "" {
|
||||
b.FailNow()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
|
Reference in New Issue