Debian Codegraph @

gauge_float64_test.go

raw symbols SCIP
1 package metrics
2
3 import "testing"
4
5 func BenchmarkGuageFloat64(b *testing.B) {
6 g := NewGaugeFloat64()
7 b.ResetTimer()
8 for i := 0; i < b.N; i++ {
9 g.Update(float64(i))
10 }
11 }
12
13 func TestGaugeFloat64(t *testing.T) {
14 g := NewGaugeFloat64()
15 g.Update(float64(47.0))
16 if v := g.Value(); float64(47.0) != v {
17 t.Errorf("g.Value(): 47.0 != %v\n", v)
18 }
19 }
20
21 func TestGaugeFloat64Snapshot(t *testing.T) {
22 g := NewGaugeFloat64()
23 g.Update(float64(47.0))
24 snapshot := g.Snapshot()
25 g.Update(float64(0))
26 if v := snapshot.Value(); float64(47.0) != v {
27 t.Errorf("g.Value(): 47.0 != %v\n", v)
28 }
29 }
30
31 func TestGetOrRegisterGaugeFloat64(t *testing.T) {
32 r := NewRegistry()
33 NewRegisteredGaugeFloat64("foo", r).Update(float64(47.0))
34 t.Logf("registry: %v", r)
35 if g := GetOrRegisterGaugeFloat64("foo", r); float64(47.0) != g.Value() {
36 t.Fatal(g)
37 }
38 }