aboutsummaryrefslogtreecommitdiff
path: root/src/testing/benchmark.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/benchmark.go')
-rw-r--r--src/testing/benchmark.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/testing/benchmark.go b/src/testing/benchmark.go
index c8571a5f5a..30fa106dd4 100644
--- a/src/testing/benchmark.go
+++ b/src/testing/benchmark.go
@@ -36,8 +36,9 @@ var (
)
type durationOrCountFlag struct {
- d time.Duration
- n int
+ d time.Duration
+ n int
+ allowZero bool
}
func (f *durationOrCountFlag) String() string {
@@ -50,14 +51,14 @@ func (f *durationOrCountFlag) String() string {
func (f *durationOrCountFlag) Set(s string) error {
if strings.HasSuffix(s, "x") {
n, err := strconv.ParseInt(s[:len(s)-1], 10, 0)
- if err != nil || n <= 0 {
+ if err != nil || n < 0 || (!f.allowZero && n == 0) {
return fmt.Errorf("invalid count")
}
*f = durationOrCountFlag{n: int(n)}
return nil
}
d, err := time.ParseDuration(s)
- if err != nil || d <= 0 {
+ if err != nil || d < 0 || (!f.allowZero && d == 0) {
return fmt.Errorf("invalid duration")
}
*f = durationOrCountFlag{d: d}