Skip to content

Commit 1c922f2

Browse files
committed
new: rugo bench accepts a --count flag
1 parent a89cbf0 commit 1c922f2

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

cmd/cmd.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ func Execute(version string) {
139139
Aliases: []string{"C"},
140140
Usage: "Disable ANSI color output",
141141
},
142+
&cli.IntFlag{
143+
Name: "count",
144+
Aliases: []string{"n"},
145+
Usage: "Run each benchmark file N times (best result kept)",
146+
Value: 1,
147+
},
142148
},
143149
Action: benchAction,
144150
},
@@ -855,11 +861,21 @@ func benchAction(ctx context.Context, cmd *cli.Command) error {
855861
return fmt.Errorf("no benchmark files found")
856862
}
857863

864+
count := cmd.Int("count")
865+
if count < 1 {
866+
count = 1
867+
}
868+
858869
for _, f := range files {
859870
fmt.Fprintf(os.Stderr, "=== %s ===\n", f)
860-
comp := &compiler.Compiler{}
861-
if err := comp.Run(f); err != nil {
862-
return err
871+
for i := 0; i < int(count); i++ {
872+
if count > 1 {
873+
fmt.Fprintf(os.Stderr, " --- run %d/%d ---\n", i+1, count)
874+
}
875+
comp := &compiler.Compiler{}
876+
if err := comp.Run(f); err != nil {
877+
return err
878+
}
863879
}
864880
}
865881

0 commit comments

Comments
 (0)