Files
EdgeAPI/internal/db/models/db_node_initializer_test.go

46 lines
934 B
Go
Raw Normal View History

2020-10-10 11:49:21 +08:00
package models
import (
"runtime"
"testing"
"time"
)
func TestDBNodeInitializer_loop(t *testing.T) {
initializer := NewDBNodeInitializer()
err := initializer.loop()
if err != nil {
t.Fatal(err)
}
2021-06-08 11:18:27 +08:00
t.Log(len(accessLogDBMapping), len(httpAccessLogDAOMapping))
2020-10-10 11:49:21 +08:00
}
func TestFindAccessLogTable(t *testing.T) {
before := time.Now()
db := SharedHTTPAccessLogDAO.Instance
2021-06-08 11:18:27 +08:00
tableName, err := findHTTPAccessLogTable(db, "20201010", false)
2020-10-10 11:49:21 +08:00
if err != nil {
t.Fatal(err)
}
t.Log(tableName)
t.Log(time.Since(before).Seconds()*1000, "ms")
before = time.Now()
2021-06-08 11:18:27 +08:00
tableName, err = findHTTPAccessLogTable(db, "20201010", false)
2020-10-10 11:49:21 +08:00
if err != nil {
t.Fatal(err)
}
t.Log(tableName)
t.Log(time.Since(before).Seconds()*1000, "ms")
}
func BenchmarkFindAccessLogTable(b *testing.B) {
db := SharedHTTPAccessLogDAO.Instance
runtime.GOMAXPROCS(1)
for i := 0; i < b.N; i++ {
2021-06-08 11:18:27 +08:00
_, _ = findHTTPAccessLogTable(db, "20201010", false)
2020-10-10 11:49:21 +08:00
}
}