Skip to content

Instantly share code, notes, and snippets.

@jwalton
Last active November 8, 2023 14:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwalton/2394e848be3070c6667220baa70cdeda to your computer and use it in GitHub Desktop.
Save jwalton/2394e848be3070c6667220baa70cdeda to your computer and use it in GitHub Desktop.
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