diff options
| author | Josh Bleecher Snyder <josharian@gmail.com> | 2019-03-02 11:14:29 -0800 |
|---|---|---|
| committer | Josh Bleecher Snyder <josharian@gmail.com> | 2019-03-02 19:37:02 +0000 |
| commit | 37b84e2782e5c19c3053316853a6fba923b0f06b (patch) | |
| tree | 37bd6fca27a5717121025035e951dbc50ea5862d /src/os/exec | |
| parent | 5126feadd6e4ca890da0156c59b159085959120e (diff) | |
| download | go-37b84e2782e5c19c3053316853a6fba923b0f06b.tar.xz | |
os/exec: add BenchmarkExecEcho
Change-Id: Ie955cdc505766447f70b8f262160fe05b60a5b0c
Reviewed-on: https://go-review.googlesource.com/c/164959
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/os/exec')
| -rw-r--r-- | src/os/exec/bench_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
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) + } + } +} |
