(b *testing.B)
| 48 | } |
| 49 | |
| 50 | func BenchmarkDoRequestPostJSON(b *testing.B) { |
| 51 | ctx := context.Background() |
| 52 | client := &unixSocketClient{ |
| 53 | socketPath: "/tmp/agh.sock", |
| 54 | httpClient: &http.Client{ |
| 55 | Transport: roundTripperFunc(func(req *http.Request) (*http.Response, error) { |
| 56 | if req.Body != nil { |
| 57 | if _, err := io.Copy(io.Discard, req.Body); err != nil { |
| 58 | return nil, err |
| 59 | } |
| 60 | if err := req.Body.Close(); err != nil { |
| 61 | return nil, err |
| 62 | } |
| 63 | } |
| 64 | return newHTTPResponse(http.StatusNoContent, ""), nil |
| 65 | }), |
| 66 | }, |
| 67 | } |
| 68 | |
| 69 | b.ReportAllocs() |
| 70 | for b.Loop() { |
| 71 | response, err := client.doRequest(ctx, http.MethodPost, "/api/sessions", nil, benchmarkRequestBody) |
| 72 | if err != nil { |
| 73 | b.Fatalf("doRequest() error = %v", err) |
| 74 | } |
| 75 | if err := response.Body.Close(); err != nil { |
| 76 | b.Fatalf("response.Body.Close() error = %v", err) |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | func buildBenchmarkTableRows(count int) [][]string { |
| 82 | rows := make([][]string, 0, count) |
nothing calls this directly
no test coverage detected