compilebench: factor running build tool commands
compilebench: factor running build tool commands

We do a lot of sophisticated things around running the compile command
to gather benchmark metrics from it. We're about to add a benchmark
for the linker and will want all of the same mechanism. This CL
factors this out into a function.

Change-Id: I499d15d30417618f372982404ceb3e0f9c762e5c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175800
Run-TryBot: Austin Clements <7ea35d812706d9213868749011af1ed4fa2f6aa0@google.com>
Reviewed-by: Russ Cox <5ad239cb8a44f659eaaee0aa1ea5b94947abe557@golang.org>
Reviewed-by: Cherry Zhang <d62e63aa42ce272d7b6a5055d97e942b33a34679@google.com>

golang/tools,golang/tools,golang/tools,golang/tools,golang/tools