Skip to content
Myr

Make BenchmarkBashCompletion more honest

Before adoption: this commit came in with the history the project adopted, so no landing records it.

name old time/op new time/op delta BashCompletion-4 67.4µs ± 1% 50.8µs ± 3% -24.63% (p=0.000 n=17+19) name old alloc/op new alloc/op delta BashCompletion-4 29.5kB ± 0% 29.5kB ± 0% +0.00% (p=0.020 n=20+20) name old allocs/op new allocs/op delta BashCompletion-4 253 ± 0% 253 ± 0% ~ (all equal)

authored by Albert Nigmatzianov · committed by Albert Nigmatzianov · parent 66da711 · Browse files · 1 file+3 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−7 removed

  • other:+3 added−7 removed

1 file+3 added−7 removed

modified:bash_completions_test.go+3 added-7 removed
1package cobra23import (4 "bytes"5 "io/ioutil"5 "os"6 "os/exec"7 "strings"8 "testing"
170 unmodified lines
179 c := initializeWithRootCmd()180 cmdEcho.AddCommand(cmdTimes)181 c.AddCommand(cmdEcho, cmdPrint, cmdDeprecated, cmdColon)182184 file, err := ioutil.TempFile("", "")185 if err != nil {186 b.Fatal(err)187 }188 defer os.Remove(file.Name())183 buf := new(bytes.Buffer)184185 b.ResetTimer()186 for i := 0; i < b.N; i++ {187 buf.Reset()192 if err := c.GenBashCompletion(file); err != nil {188 if err := c.GenBashCompletion(buf); err != nil {189 b.Fatal(err)190 }191 }192}