2020-11-07 19:40:24 +08:00
|
|
|
package models
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
_ "github.com/go-sql-driver/mysql"
|
2020-11-09 10:44:00 +08:00
|
|
|
"github.com/iwind/TeaGo/dbs"
|
2020-11-07 19:40:24 +08:00
|
|
|
"runtime"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestIPListDAO_IncreaseVersion(t *testing.T) {
|
2020-11-09 10:44:00 +08:00
|
|
|
dbs.NotifyReady()
|
|
|
|
|
|
2020-11-07 19:40:24 +08:00
|
|
|
dao := NewIPListDAO()
|
2020-11-09 10:44:00 +08:00
|
|
|
version, err := dao.IncreaseVersion()
|
2020-11-07 19:40:24 +08:00
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
t.Log("version:", version)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func BenchmarkIPListDAO_IncreaseVersion(b *testing.B) {
|
|
|
|
|
runtime.GOMAXPROCS(1)
|
|
|
|
|
|
2020-11-09 10:44:00 +08:00
|
|
|
dbs.NotifyReady()
|
|
|
|
|
|
2020-11-07 19:40:24 +08:00
|
|
|
dao := NewIPListDAO()
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
2020-11-09 10:44:00 +08:00
|
|
|
_, _ = dao.IncreaseVersion()
|
2020-11-07 19:40:24 +08:00
|
|
|
}
|
|
|
|
|
}
|