From 37b84e2782e5c19c3053316853a6fba923b0f06b Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Sat, 2 Mar 2019 11:14:29 -0800 Subject: [PATCH] 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 --- src/os/exec/bench_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/os/exec/bench_test.go 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) + } + } +} -- 2.48.1