aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/os/env_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/os/env_test.go b/src/os/env_test.go
index 78c8fe57cb..0198f1925d 100644
--- a/src/os/env_test.go
+++ b/src/os/env_test.go
@@ -62,6 +62,22 @@ func TestExpand(t *testing.T) {
}
}
+func BenchmarkExpand(b *testing.B) {
+ var s string
+ b.Run("noop", func(b *testing.B) {
+ b.ReportAllocs()
+ for i := 0; i < b.N; i++ {
+ s = Expand("tick tick tick tick", func(string) string { return "" })
+ }
+ })
+ b.Run("multiple", func(b *testing.B) {
+ b.ReportAllocs()
+ for i := 0; i < b.N; i++ {
+ s = Expand("$a $a $a $a", func(string) string { return "boom" })
+ }
+ })
+}
+
func TestConsistentEnviron(t *testing.T) {
e0 := Environ()
for i := 0; i < 10; i++ {