本文整理匯總了Golang中github.com/codahale/metrics.Histogram類的典型用法代碼示例。如果您正苦於以下問題:Golang Histogram類的具體用法?Golang Histogram怎麽用?Golang Histogram使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Histogram類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: logBatchCommit
func logBatchCommit(b datastore.Batch, n int, num, errs metrics.Counter, lat *metrics.Histogram) error {
if n > 0 {
before := time.Now()
err := b.Commit()
took := int(time.Now().Sub(before)/time.Microsecond) / n
num.AddN(uint64(n))
for i := 0; i < n; i++ {
_ = lat.RecordValue(int64(took))
}
if err != nil {
errs.Add()
return err
}
}
return nil
}
示例2: recordLatency
func recordLatency(h *metrics.Histogram, start time.Time) {
elapsed := time.Now().Sub(start) / time.Microsecond
_ = h.RecordValue(int64(elapsed))
}
示例3: Measure
func Measure(h *metrics.Histogram, d time.Duration) {
if h != nil && archaius.Conf.Collect {
h.RecordValue(int64(d))
metrics.Counter(h.Name()).Add()
}
}