processBench runs bench b and prints the results.
(ctx *benchContext)
| 454 | |
| 455 | // processBench runs bench b and prints the results. |
| 456 | func (b *B) processBench(ctx *benchContext) { |
| 457 | benchName := b.name |
| 458 | |
| 459 | for i := 0; i < flagCount; i++ { |
| 460 | if ctx != nil { |
| 461 | fmt.Printf("%-*s\t", ctx.maxLen, benchName) |
| 462 | } |
| 463 | r := b.doBench() |
| 464 | if b.failed { |
| 465 | // The output could be very long here, but probably isn't. |
| 466 | // We print it all, regardless, because we don't want to trim the reason |
| 467 | // the benchmark failed. |
| 468 | fmt.Printf("--- FAIL: %s\n%s", benchName, "") // b.output) |
| 469 | return |
| 470 | } |
| 471 | if ctx != nil { |
| 472 | results := r.String() |
| 473 | |
| 474 | if *benchmarkMemory || b.showAllocResult { |
| 475 | results += "\t" + r.MemString() |
| 476 | } |
| 477 | fmt.Println(results) |
| 478 | |
| 479 | // Print any benchmark output |
| 480 | if b.output.Len() > 0 { |
| 481 | fmt.Printf("--- BENCH: %s\n", benchName) |
| 482 | b.output.WriteTo(os.Stdout) |
| 483 | } |
| 484 | } |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | // Run benchmarks f as a subbenchmark with the given name. It reports |
| 489 | // true if the subbenchmark succeeded. |