2022-11-02 03:48:19 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2024-08-05 23:28:36 -07:00
|
|
|
"fmt"
|
2022-11-02 03:48:19 -07:00
|
|
|
"testing"
|
2022-12-28 08:30:48 -08:00
|
|
|
|
2023-01-05 12:57:38 -08:00
|
|
|
"github.com/jandedobbeleer/oh-my-posh/src/cli"
|
2024-11-06 23:42:21 -08:00
|
|
|
"github.com/jandedobbeleer/oh-my-posh/src/prompt"
|
2022-11-02 03:48:19 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkInit(b *testing.B) {
|
|
|
|
cmd := cli.RootCmd
|
2022-11-02 07:04:20 -07:00
|
|
|
// needs to be a non-existing file as we panic otherwise
|
2024-08-05 23:28:36 -07:00
|
|
|
cmd.SetArgs([]string{"init", "fish", "--print", "--silent"})
|
2022-11-02 03:48:19 -07:00
|
|
|
out := bytes.NewBufferString("")
|
|
|
|
cmd.SetOut(out)
|
|
|
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = cmd.Execute()
|
|
|
|
}
|
|
|
|
}
|
2022-11-02 07:04:20 -07:00
|
|
|
|
|
|
|
func BenchmarkPrimary(b *testing.B) {
|
|
|
|
cmd := cli.RootCmd
|
|
|
|
// needs to be a non-existing file as we panic otherwise
|
2024-11-06 23:42:21 -08:00
|
|
|
cmd.SetArgs([]string{"print", prompt.PRIMARY, "--pwd", "/Users/jan/Code/oh-my-posh/src", "--shell", "fish", "--silent"})
|
2022-11-02 07:04:20 -07:00
|
|
|
out := bytes.NewBufferString("")
|
|
|
|
cmd.SetOut(out)
|
|
|
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = cmd.Execute()
|
|
|
|
}
|
2024-08-05 23:28:36 -07:00
|
|
|
|
|
|
|
fmt.Println("")
|
2022-11-02 07:04:20 -07:00
|
|
|
}
|