-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
71 lines (61 loc) · 1.81 KB
/
main.go
File metadata and controls
71 lines (61 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"fmt"
"os"
"github.com/fezcode/atlas.bench/pkg/bench"
"github.com/fezcode/atlas.bench/pkg/ui"
"github.com/spf13/pflag"
)
var Version = "dev"
func printHelp() {
fmt.Println("Atlas Bench — high-precision benchmarking TUI for CLI commands.")
fmt.Println()
fmt.Println("Usage:")
fmt.Println(" atlas.bench [options] \"command1\" \"command2\" ...")
fmt.Println()
fmt.Println("Options:")
fmt.Println(" -r, --runs int Timed iterations per command (default 10)")
fmt.Println(" -w, --warmup int Unmeasured warm-up runs (default 3)")
fmt.Println(" -t, --timeout dur Per-run timeout (e.g. 5s, 100ms; 0 = none)")
fmt.Println(" -s, --shell string Shell to use (default auto)")
fmt.Println(" -v, --version Show version")
fmt.Println(" -h, --help Show this help")
fmt.Println()
fmt.Println("Inside the UI:")
fmt.Println(" ↑↓/jk navigate ↵ toggle detail r restart q quit")
}
func main() {
if len(os.Args) > 1 {
switch os.Args[1] {
case "-v", "--version":
fmt.Printf("atlas.bench v%s\n", Version)
return
case "-h", "--help", "help":
printHelp()
return
}
}
runs := pflag.IntP("runs", "r", 10, "Timed iterations per command")
warmup := pflag.IntP("warmup", "w", 3, "Unmeasured warm-up runs")
timeout := pflag.DurationP("timeout", "t", 0, "Per-run timeout")
shell := pflag.StringP("shell", "s", "", "Shell to use")
pflag.BoolP("version", "v", false, "Show version")
pflag.Usage = printHelp
pflag.Parse()
commands := pflag.Args()
if len(commands) == 0 {
printHelp()
os.Exit(1)
}
cfg := bench.Config{
Commands: commands,
Runs: *runs,
Warmup: *warmup,
Timeout: *timeout,
Shell: *shell,
}
if err := ui.Start(Version, cfg); err != nil {
fmt.Printf("Error starting UI: %v\n", err)
os.Exit(1)
}
}