Esempio n. 1
0
func quickFn(c *bench.Context) {
	t := time.Now()
	for i := 0; i < 1000*1000; i++ {
	}
	c.Timer("Latency", time.Since(t))
	c.Incr("Call Counter", 1)
	//c.Incr("Another Call Counter", 10)
}
Esempio n. 2
0
func f(c *bench.Context) {
	var client *http.Client
	v, ok := c.Values["client"]
	if !ok {
		client = &http.Client{}
		c.Incr("Counter", 1)
		c.Values["client"] = client
	} else {
		client = v.(*http.Client)
	}

	start := time.Now()
	resp, err := client.Get("http://localhost:8000")
	if err != nil {
		fmt.Printf("Error :  %s\n", err)
		//c.Incr("Errors", 1)
		return
	}
	defer resp.Body.Close()
	c.Timer("Latency", time.Since(start))
	// c.Incr("Counter", 1)
}
Esempio n. 3
0
func delayedFn(c *bench.Context) {
	t := time.Now()
	time.Sleep(100 * time.Millisecond)
	c.Timer("Latency", time.Since(t))
	c.Incr("Call Counter", 1)
}