MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / init

Function init

internal/utils/dbs/query_stat_manager.go:17–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15)
16
17func init() {
18 if !teaconst.IsMain {
19 return
20 }
21
22 var ticker = time.NewTicker(5 * time.Second)
23
24 events.On(events.EventLoaded, func() {
25 if teaconst.EnableDBStat {
26 goman.New(func() {
27 for range ticker.C {
28 var stats = []string{}
29 for _, stat := range SharedQueryStatManager.TopN(10) {
30 var avg = stat.CostTotal / float64(stat.Calls)
31 var query = stat.Query
32 if len(query) > 128 {
33 query = query[:128]
34 }
35 stats = append(stats, fmt.Sprintf("%.2fms/%.2fms/%.2fms - %d - %s", stat.CostMin*1000, stat.CostMax*1000, avg*1000, stat.Calls, query))
36 }
37 logs.Println("\n========== DB STATS ==========\n" + strings.Join(stats, "\n") + "\n=============================")
38 }
39 })
40 }
41 })
42}
43
44var SharedQueryStatManager = NewQueryStatManager()
45

Callers

nothing calls this directly

Calls 3

OnFunction · 0.92
NewFunction · 0.92
TopNMethod · 0.80

Tested by

no test coverage detected