-
Notifications
You must be signed in to change notification settings - Fork 7
/
gchalk_benchmark_test.go
59 lines (49 loc) · 1.07 KB
/
gchalk_benchmark_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package gchalk
import (
"testing"
)
var benchGChalk = New(ForceLevel(LevelAnsi16m))
func BenchmarkColor(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
benchGChalk.Red("Hello world!")
}
}
var red = benchGChalk.Red
func BenchmarkPreDefinedColor(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
red("Hello world!")
}
}
func BenchmarkRgb(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
benchGChalk.RGB(10, 30, 255)("Hello world!")
}
}
var rgbTest = benchGChalk.RGB(10, 30, 255)
func BenchmarkPreDefinedRgb(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
rgbTest("Hello world!")
}
}
func BenchmarkComposed(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
benchGChalk.WithBgBlue().WithBold().Red("Hello world!")
}
}
func BenchmarkNested(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
benchGChalk.Red("Hello", benchGChalk.Green("green"), "world!")
}
}
func BenchmarkStyle(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
benchGChalk.StyleMust("red")("Hello world!")
}
}