Skip to content

Commit

Permalink
benchcmd: pass stdout/stderr through
Browse files Browse the repository at this point in the history
  • Loading branch information
aclements committed Sep 19, 2022
1 parent 7f761d4 commit 4600a79
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion benchcmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ func main() {
args := flag.Args()[1:]

for i := 0; i < *n; i++ {
fmt.Printf("Benchmark%s\t", benchname)
cmd := exec.Command(args[0], args[1:]...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
before := time.Now()
if err := cmd.Run(); err != nil {
fmt.Println(err)
os.Exit(1)
}
after := time.Now()
fmt.Printf("Benchmark%s\t", benchname)
fmt.Printf("%d\t%d ns/op", 1, after.Sub(before))
fmt.Printf("\t%d user-ns/op\t%d sys-ns/op", cmd.ProcessState.UserTime(), cmd.ProcessState.SystemTime())
if ru, ok := cmd.ProcessState.SysUsage().(*syscall.Rusage); ok {
Expand Down

0 comments on commit 4600a79

Please sign in to comment.