Thanks, fixing those fixed the benchmarks, but unfortunately that just
makes it more difficult to demonstrate the problem objectively.
The real issue is that, from a user's perspective this code is zippy:
cmd := exec.Command("more", "foo.go")
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Start(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
}
if err := cmd.Wait(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
}
while this code (with the same WrapperStruct{} from above) is
noticeably slow and clunky.
cmd := exec.Command("more", "foo.go")
cmd.Stdin = WrapperStruct{}
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Start(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
}
if err := cmd.Wait(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
}
But I don't know of a good way to benchmark reading user input for an
interactive exec.Cmd.
--
- Dave