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

Method Sum

internal/rpc/call_stat.go:44–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42}
43
44func (this *CallStat) Sum() (successPercent float64, avgCostSeconds float64) {
45 this.locker.Lock()
46 defer this.locker.Unlock()
47
48 var size = this.size
49 if size <= 0 {
50 size = 10
51 }
52
53 var totalItems = len(this.items)
54 if totalItems <= size/2 /** 低于一半的采样率,不计入统计 **/ {
55 successPercent = 100
56 return
57 }
58
59 var totalOkItems = 0
60 var totalCostSeconds float64
61 for _, item := range this.items {
62 if item.ok {
63 totalOkItems++
64 }
65 totalCostSeconds += item.costSeconds
66 }
67 successPercent = float64(totalOkItems) * 100 / float64(totalItems)
68 avgCostSeconds = totalCostSeconds / float64(totalItems)
69
70 return
71}

Callers 5

updateMethod · 0.45
installMethod · 0.45
TestNewCallStatFunction · 0.45
PerformMethod · 0.45
validateGeeTestFormMethod · 0.45

Calls 2

LockMethod · 0.45
UnlockMethod · 0.45

Tested by 1

TestNewCallStatFunction · 0.36