MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / ToMap

Method ToMap

utils/timer/timer.go:65–90  ·  view source on GitHub ↗

ToMap returns analysis results as time duration map.

()

Source from the content-addressed store, hash-verified

63
64// ToMap returns analysis results as time duration map.
65func (t *Timer) ToMap() map[string]time.Duration {
66 t.Lock()
67 defer t.Unlock()
68
69 // calc
70 lp := len(t.pivots)
71 m := make(map[string]time.Duration, 1+lp)
72
73 for i := 0; i != lp; i++ {
74 var d time.Duration
75 if i == 0 {
76 d = t.pivots[i].Sub(t.start)
77 } else {
78 d = t.pivots[i].Sub(t.pivots[i-1])
79 }
80
81 m[t.names[i]] = d
82
83 if i+1 == lp {
84 // last one
85 m["total"] = t.pivots[i].Sub(t.start)
86 }
87 }
88
89 return m
90}

Callers 2

TestTimerFunction · 0.95
ToLogFieldsMethod · 0.95

Calls

no outgoing calls

Tested by 1

TestTimerFunction · 0.76