예제 #1
0
func BenchmarkGauge(b *testing.B) {
	c := New(ioutil.Discard)

	b.RunParallel(func(p *testing.PB) {
		for p.Next() {
			c.Gauge("free.memory", 512, "program:counters")
		}
	})
}
예제 #2
0
func BenchmarkUnique(b *testing.B) {
	c := New(ioutil.Discard)

	b.RunParallel(func(p *testing.PB) {
		for p.Next() {
			c.Unique("users", "1", "program:counters")
		}
	})
}
예제 #3
0
func BenchmarkDuration(b *testing.B) {
	c := New(ioutil.Discard)

	b.RunParallel(func(p *testing.PB) {
		for p.Next() {
			c.Duration("response.time", time.Second, "program:counters")
		}
	})
}
예제 #4
0
func BenchmarkHistogram(b *testing.B) {
	c := New(ioutil.Discard)

	b.RunParallel(func(p *testing.PB) {
		for p.Next() {
			c.Histogram("response.size", 512, "program:server")
		}
	})
}
예제 #5
0
func BenchmarkDecr(b *testing.B) {
	c := New(ioutil.Discard)

	b.RunParallel(func(p *testing.PB) {
		for p.Next() {
			c.Decr("counter", "program:counters")
		}
	})
}
예제 #6
0
func BenchmarkChanson(b *testing.B) {
	lo := buildLargeObject(b.N)
	b.ResetTimer()

	cs := New(ioutil.Discard)
	cs.Object(func(obj Object) {
		for k, v := range lo {
			obj.Set(k, v)
		}
	})
}
예제 #7
0
func ExampleObject() {
	buf := bytes.NewBuffer(nil)
	cs := New(ioutil.Discard)
	cs.Object(func(obj Object) {
		obj.Set("foo", "bar")
		obj.Set("fun", func(enc *json.Encoder) {
			enc.Encode([]int{1, 2, 3})
		})
	})

	fmt.Printf("%v", buf.String())
}