This commit is contained in:
2018-11-04 15:58:15 +01:00
commit f956bcee28
1178 changed files with 584552 additions and 0 deletions

38
vendor/github.com/anacrolix/missinggo/perf/event.go generated vendored Normal file
View File

@@ -0,0 +1,38 @@
package perf
import (
"math"
"sync"
"time"
)
type Event struct {
Mu sync.RWMutex
Count int64
Total time.Duration
Min time.Duration
Max time.Duration
}
func (e *Event) Add(t time.Duration) {
e.Mu.Lock()
defer e.Mu.Unlock()
if t > e.Max {
e.Max = t
}
if t < e.Min {
e.Min = t
}
e.Count++
e.Total += t
}
func (e *Event) MeanTime() time.Duration {
e.Mu.RLock()
defer e.Mu.RUnlock()
return e.Total / time.Duration(e.Count)
}
func (e *Event) Init() {
e.Min = math.MaxInt64
}