]> Cypherpunks repositories - gostls13.git/commitdiff
os/exec: add BenchmarkExecEcho
authorJosh Bleecher Snyder <josharian@gmail.com>
Sat, 2 Mar 2019 19:14:29 +0000 (11:14 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Sat, 2 Mar 2019 19:37:02 +0000 (19:37 +0000)
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>
src/os/exec/bench_test.go [new file with mode: 0644]

diff --git a/src/os/exec/bench_test.go b/src/os/exec/bench_test.go
new file mode 100644 (file)
index 0000000..e8cf73b
--- /dev/null
@@ -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)
+               }
+       }
+}