Esempio n. 1
0
File: measure.go Progetto: rht/bssim
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
}
Esempio n. 2
0
File: measure.go Progetto: rht/bssim
func recordLatency(h *metrics.Histogram, start time.Time) {
	elapsed := time.Now().Sub(start) / time.Microsecond
	_ = h.RecordValue(int64(elapsed))
}
Esempio n. 3
0
func Measure(h *metrics.Histogram, d time.Duration) {
	if h != nil && archaius.Conf.Collect {
		h.RecordValue(int64(d))
		metrics.Counter(h.Name()).Add()
	}
}