MCPcopy
hub / github.com/grpc/grpc-go / NewTimer

Method NewTimer

internal/profiling/profiling.go:157–171  ·  view source on GitHub ↗

NewTimer creates a Timer object within the given stat if stat is non-nil. The value passed in tags will be attached to the newly created Timer. NewTimer also automatically sets the Begin value of the Timer to the current time. The user is expected to call stat.Egress with the returned index as argum

(tags string)

Source from the content-addressed store, hash-verified

155// time. The user is expected to call stat.Egress with the returned index as
156// argument to mark the end.
157func (stat *Stat) NewTimer(tags string) *Timer {
158 if stat == nil {
159 return nil
160 }
161
162 timer := &Timer{
163 Tags: tags,
164 GoID: goid(),
165 Begin: time.Now(),
166 }
167 stat.mu.Lock()
168 stat.Timers = append(stat.Timers, timer)
169 stat.mu.Unlock()
170 return timer
171}
172
173// AppendTimer appends a given Timer object to the internal slice of timers. A
174// deep copy of the timer is made (i.e. no reference is retained to this

Callers 15

TestProfilingMethod · 0.95
TestProfilingRaceMethod · 0.95
BenchmarkProfilingFunction · 0.95
ServeMethod · 0.80
shouldRetryMethod · 0.80
serverAndClientHandshakeFunction · 0.80
initCacheEntriesFunction · 0.80

Calls 4

NowMethod · 0.80
goidFunction · 0.70
LockMethod · 0.45
UnlockMethod · 0.45