From: Josh Bleecher Snyder Date: Sat, 2 Mar 2019 19:14:29 +0000 (-0800) Subject: os/exec: add BenchmarkExecEcho X-Git-Tag: go1.13beta1~1250 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=37b84e2782e5c19c3053316853a6fba923b0f06b;p=gostls13.git os/exec: add BenchmarkExecEcho Change-Id: Ie955cdc505766447f70b8f262160fe05b60a5b0c Reviewed-on: https://go-review.googlesource.com/c/164959 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/os/exec/bench_test.go b/src/os/exec/bench_test.go new file mode 100644 index 0000000000..e8cf73bef7 --- /dev/null +++ b/src/os/exec/bench_test.go @@ -0,0 +1,23 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package exec + +import ( + "testing" +) + +func BenchmarkExecEcho(b *testing.B) { + b.ReportAllocs() + path, err := LookPath("echo") + if err != nil { + b.Fatalf("could not find echo: %v", err) + } + b.ResetTimer() + for i := 0; i < b.N; i++ { + if err := Command(path).Run(); err != nil { + b.Fatalf("echo: %v", err) + } + } +}