Esempio n. 1
0
// benchmarkGet runs the benchmark on the Table.Lookup() function with the
// given matcher and picker functions.
func benchmarkGet(t Table, m matcher, p picker, pb *testing.PB) {
	reqs := makeRequests(t)
	match, pick = m, p
	k, n := len(reqs), 0
	for pb.Next() {
		t.Lookup(reqs[n%k], "")
		n++
	}
}
func runRequests(b *testing.B, pb *testing.PB, c *fasthttp.HostClient) {
	var req fasthttp.Request
	req.SetRequestURI("http://foo.bar/baz")
	var resp fasthttp.Response
	for pb.Next() {
		if err := c.Do(&req, &resp); err != nil {
			b.Fatalf("unexpected error: %s", err)
		}
		if resp.StatusCode() != fasthttp.StatusOK {
			b.Fatalf("unexpected status code: %d. Expecting %d", resp.StatusCode(), fasthttp.StatusOK)
		}
	}
}
Esempio n. 3
0
func benchmarkConvLayerParallel(pb *testing.PB, layer *ConvLayer, input *autofunc.Variable,
	upstream linalg.Vector, grad autofunc.Gradient) {
	for pb.Next() {
		layer.Apply(input).PropagateGradient(upstream, grad)
	}
}