Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gawk Benchmark
package main
import (
"testing"
"github.com/fatih/color"
"github.com/jwalton/gchalk"
"github.com/logrusorgru/aurora"
"github.com/mgutz/ansi"
"github.com/muesli/termenv"
)
func BenchmarkGchalk(b *testing.B) {
for i := 0; i < b.N; i++ {
gchalk.Red("Hello world!")
}
}
func BenchmarkAurora(b *testing.B) {
for i := 0; i < b.N; i++ {
aurora.Red("Hello world!").String()
}
}
var faithRed = color.New(color.FgRed).SprintfFunc()
func BenchmarkFatih(b *testing.B) {
for i := 0; i < b.N; i++ {
faithRed("Hello world!")
}
}
var ansiRed = ansi.ColorFunc("red")
func BenchmarkAnsi(b *testing.B) {
for i := 0; i < b.N; i++ {
ansiRed("Hello world!")
}
}
var termenvProfile = termenv.TrueColor
var termenvRed = termenvProfile.Color("1")
func BenchmarkTermenv(b *testing.B) {
for i := 0; i < b.N; i++ {
s := termenv.String("Hello world!").Foreground(termenvRed)
s.String()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment