(b *testing.B, path string, needDot bool)
| 307 | func BenchmarkDot(b *testing.B) { benchmarkURL(b, "/", true) } |
| 308 | |
| 309 | func benchmarkURL(b *testing.B, path string, needDot bool) { |
| 310 | if needDot { |
| 311 | if _, err := exec.LookPath("dot"); err != nil { |
| 312 | b.Skip("dot not available") |
| 313 | } |
| 314 | } |
| 315 | prof := largeProfile(b) |
| 316 | server := makeTestServer(b, prof) |
| 317 | url := server.URL + path |
| 318 | b.ResetTimer() |
| 319 | for i := 0; i < b.N; i++ { |
| 320 | res, err := http.Get(url) |
| 321 | if err != nil { |
| 322 | b.Fatal(err) |
| 323 | } |
| 324 | data, err := io.ReadAll(res.Body) |
| 325 | if err != nil { |
| 326 | b.Fatal(err) |
| 327 | } |
| 328 | if i == 0 && testing.Verbose() { |
| 329 | b.Logf("%-12s : %10d bytes", path, len(data)) |
| 330 | } |
| 331 | } |
| 332 | } |
no test coverage detected
searching dependent graphs…