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

Method TopN

internal/utils/dbs/query_stat_manager.go:73–89  ·  view source on GitHub ↗
(n int)

Source from the content-addressed store, hash-verified

71}
72
73func (this *QueryStatManager) TopN(n int) []*QueryStat {
74 this.locker.Lock()
75 defer this.locker.Unlock()
76
77 var stats = []*QueryStat{}
78 for _, stat := range this.statsMap {
79 stats = append(stats, stat)
80 }
81 sort.Slice(stats, func(i, j int) bool {
82 return stats[i].CostMax > stats[j].CostMax
83 })
84
85 if len(stats) > n {
86 return stats[:n]
87 }
88 return stats
89}

Callers 2

TestQueryStatManagerFunction · 0.80
initFunction · 0.80

Calls 2

LockMethod · 0.45
UnlockMethod · 0.45

Tested by 1

TestQueryStatManagerFunction · 0.64