基准测试

This commit is contained in:
suguo.yao 2021-09-04 11:03:51 +08:00
parent a86a576ace
commit c03c0f06ab
1 changed files with 14 additions and 0 deletions

View File

@ -1,6 +1,8 @@
package test package test
import ( import (
"fmt"
"math/rand"
"testing" "testing"
"myschools.me/suguo/snippet/sqlite" "myschools.me/suguo/snippet/sqlite"
@ -38,3 +40,15 @@ func TestSqlite(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
} }
func BenchmarkSqlite(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
m := rand.Intn(100) + 1
n := rand.Intn(m)
for i := 0; i < n; i++ {
fmt.Sprintf("%d", i)
}
}
})
}