Codebase list golang-github-vbauerster-mpb / 78063c2
correct bench name Vladimir Bauer 5 years ago
2 changed file(s) with 39 addition(s) and 39 deletion(s). Raw diff Collapse all Expand all
+0
-39
cwriter/clear_lines_bench_test.go less more
0 package cwriter
1
2 import (
3 "bytes"
4 "fmt"
5 "io/ioutil"
6 "strconv"
7 "testing"
8 )
9
10 func BenchmarkWithFprintf(b *testing.B) {
11 cuuAndEd := "\x1b[%dA\x1b[J"
12 for i := 0; i < b.N; i++ {
13 fmt.Fprintf(ioutil.Discard, cuuAndEd, 4)
14 }
15 }
16
17 func BenchmarkWithJoin(b *testing.B) {
18 bCuuAndEd := [][]byte{[]byte("\x1b["), []byte("A\x1b[J")}
19 for i := 0; i < b.N; i++ {
20 ioutil.Discard.Write(bytes.Join(bCuuAndEd, []byte(strconv.Itoa(4))))
21 }
22 }
23
24 func BenchmarkWithAppend(b *testing.B) {
25 escOpen := []byte("\x1b[")
26 cuuAndEd := []byte("A\x1b[J")
27 for i := 0; i < b.N; i++ {
28 ioutil.Discard.Write(append(strconv.AppendInt(escOpen, 4, 10), cuuAndEd...))
29 }
30 }
31
32 func BenchmarkWithCopy(b *testing.B) {
33 w := New(ioutil.Discard)
34 w.lineCount = 4
35 for i := 0; i < b.N; i++ {
36 w.ansiCuuAndEd()
37 }
38 }
0 package cwriter
1
2 import (
3 "bytes"
4 "fmt"
5 "io/ioutil"
6 "strconv"
7 "testing"
8 )
9
10 func BenchmarkWithFprintf(b *testing.B) {
11 cuuAndEd := "\x1b[%dA\x1b[J"
12 for i := 0; i < b.N; i++ {
13 fmt.Fprintf(ioutil.Discard, cuuAndEd, 4)
14 }
15 }
16
17 func BenchmarkWithJoin(b *testing.B) {
18 bCuuAndEd := [][]byte{[]byte("\x1b["), []byte("A\x1b[J")}
19 for i := 0; i < b.N; i++ {
20 ioutil.Discard.Write(bytes.Join(bCuuAndEd, []byte(strconv.Itoa(4))))
21 }
22 }
23
24 func BenchmarkWithAppend(b *testing.B) {
25 escOpen := []byte("\x1b[")
26 cuuAndEd := []byte("A\x1b[J")
27 for i := 0; i < b.N; i++ {
28 ioutil.Discard.Write(append(strconv.AppendInt(escOpen, 4, 10), cuuAndEd...))
29 }
30 }
31
32 func BenchmarkWithCopy(b *testing.B) {
33 w := New(ioutil.Discard)
34 w.lineCount = 4
35 for i := 0; i < b.N; i++ {
36 w.ansiCuuAndEd()
37 }
38 }