mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 07:50:25 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			46 lines
		
	
	
		
			934 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			934 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package models
 | 
						|
 | 
						|
import (
 | 
						|
	"runtime"
 | 
						|
	"testing"
 | 
						|
	"time"
 | 
						|
)
 | 
						|
 | 
						|
func TestDBNodeInitializer_loop(t *testing.T) {
 | 
						|
	initializer := NewDBNodeInitializer()
 | 
						|
	err := initializer.loop()
 | 
						|
	if err != nil {
 | 
						|
		t.Fatal(err)
 | 
						|
	}
 | 
						|
	t.Log(len(accessLogDBMapping), len(httpAccessLogDAOMapping))
 | 
						|
}
 | 
						|
 | 
						|
func TestFindAccessLogTable(t *testing.T) {
 | 
						|
	before := time.Now()
 | 
						|
	db := SharedHTTPAccessLogDAO.Instance
 | 
						|
	tableName, err := findHTTPAccessLogTable(db, "20201010", false)
 | 
						|
	if err != nil {
 | 
						|
		t.Fatal(err)
 | 
						|
	}
 | 
						|
	t.Log(tableName)
 | 
						|
	t.Log(time.Since(before).Seconds()*1000, "ms")
 | 
						|
 | 
						|
	before = time.Now()
 | 
						|
	tableName, err = findHTTPAccessLogTable(db, "20201010", false)
 | 
						|
 | 
						|
	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++ {
 | 
						|
		_, _ = findHTTPAccessLogTable(db, "20201010", false)
 | 
						|
	}
 | 
						|
}
 |