Commit 3cb067d7 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

os: add Expand benchmarks

Change-Id: I68e65591cc50433f97a97027e3ae3b452451adf2
Reviewed-on: https://go-review.googlesource.com/106696
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 7da88b83
...@@ -62,6 +62,22 @@ func TestExpand(t *testing.T) { ...@@ -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) { func TestConsistentEnviron(t *testing.T) {
e0 := Environ() e0 := Environ()
for i := 0; i < 10; i++ { for i := 0; i < 10; i++ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment