OSDN Git Service

add package
[bytom/vapor.git] / metrics / bench_test.go
1 package metrics
2
3 import (
4         "fmt"
5         "io/ioutil"
6         "testing"
7         "time"
8 )
9
10 func BenchmarkRecord(b *testing.B) {
11         rot := NewRotatingLatency(5, time.Second)
12         for i := 0; i < b.N; i++ {
13                 rot.Record(0)
14         }
15 }
16
17 func BenchmarkStringFormat(b *testing.B) {
18         rot := NewRotatingLatency(5, time.Second)
19         for i := 0; i < b.N; i++ {
20                 fmt.Fprintf(ioutil.Discard, "%s", rot)
21         }
22 }