github.com/TeaOSLab/EdgeNode@v1.3.8/internal/utils/dbs/query_stat_manager_test.go (about) 1 // Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. 2 3 package dbs_test 4 5 import ( 6 "github.com/TeaOSLab/EdgeNode/internal/utils/dbs" 7 "github.com/iwind/TeaGo/logs" 8 "testing" 9 "time" 10 ) 11 12 func TestQueryStatManager(t *testing.T) { 13 var manager = dbs.NewQueryStatManager() 14 { 15 var label = manager.AddQuery("sql 1") 16 time.Sleep(1 * time.Second) 17 label.End() 18 } 19 manager.AddQuery("sql 1").End() 20 manager.AddQuery("sql 2").End() 21 for _, stat := range manager.TopN(10) { 22 logs.PrintAsJSON(stat, t) 23 } 24 }