Last active
November 8, 2023 14:04
-
-
Save jwalton/2394e848be3070c6667220baa70cdeda to your computer and use it in GitHub Desktop.
Gawk Benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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