|
@@ -138,13 +138,18 @@ func BenchmarkLine(b *testing.B) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// Using RenderUppercase vs. RenderBlueYellow
|
|
|
+// BenchmarkLineRender-4 739462 1709 ns/op 376 B/op 13 allocs/op
|
|
|
+// BenchmarkLineRender-4 862102 1434 ns/op 648 B/op 9 allocs/op
|
|
|
+
|
|
|
func BenchmarkLineRender(b *testing.B) {
|
|
|
Unicode = false
|
|
|
+ var rf ColorRender = RenderUppercase("RED", "GREEN")
|
|
|
|
|
|
for n := 0; n < b.N; n++ {
|
|
|
var lineBuff *bytes.Buffer = &bytes.Buffer{}
|
|
|
lineBuff.WriteString(fmt.Sprintf("Line %d of %d", n, b.N))
|
|
|
- var line Line = Line{Text: lineBuff, RenderF: RenderBlueYellow}
|
|
|
+ var line Line = Line{Text: lineBuff, RenderF: rf} // RenderBlueYellow}
|
|
|
var output []byte = line.Output()
|
|
|
_ = output
|
|
|
}
|
|
@@ -152,12 +157,16 @@ func BenchmarkLineRender(b *testing.B) {
|
|
|
|
|
|
// Benchmarks / profiling
|
|
|
|
|
|
+// BenchmarkLineColor-4 2868162 403.9 ns/op 8 B/op 0 allocs/op
|
|
|
+// BenchmarkLineColor-4 2944704 400.0 ns/op 8 B/op 0 allocs/op
|
|
|
+// No change making Color strings to []byte. (reverted change)
|
|
|
+
|
|
|
func BenchmarkLineColor(b *testing.B) {
|
|
|
|
|
|
- var Up string = ColorText("BLUE")
|
|
|
- var Down string = ColorText("BOLD BLUE")
|
|
|
- var Num string = ColorText("BRI GREEN")
|
|
|
- var Sym string = ColorText("CYAN")
|
|
|
+ var Up = ColorText("BLUE")
|
|
|
+ var Down = ColorText("BOLD BLUE")
|
|
|
+ var Num = ColorText("BRI GREEN")
|
|
|
+ var Sym = ColorText("CYAN")
|
|
|
|
|
|
var render = func(output *bytes.Buffer, text []byte) []byte {
|
|
|
output.Reset()
|