44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"flag"
|
|
"fmt"
|
|
"io"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
type options struct {
|
|
grace, wait time.Duration
|
|
sizes []int
|
|
output string
|
|
}
|
|
|
|
func parseOptions(args []string, out io.Writer) (options, error) {
|
|
var o options
|
|
f := flag.NewFlagSet("reconcilebench", flag.ContinueOnError)
|
|
f.SetOutput(out)
|
|
f.DurationVar(&o.grace, "grace", 2*time.Minute, "reconciler grace (minimum 2m)")
|
|
f.DurationVar(&o.wait, "wait", 125*time.Second, "actual S3 aging wait (must exceed grace by at least 1s)")
|
|
f.StringVar(&o.output, "output", "", "also save measurement records as a JSON array at this path")
|
|
sizes := f.String("sizes", "100,1000,5000", "strictly increasing referenced object counts")
|
|
if err := f.Parse(args); err != nil {
|
|
return o, err
|
|
}
|
|
if f.NArg() != 0 || o.grace < 2*time.Minute || o.wait-o.grace < time.Second {
|
|
return o, errors.New("no positional arguments; grace >= 2m and wait >= grace+1s required")
|
|
}
|
|
last := 0
|
|
for _, raw := range strings.Split(*sizes, ",") {
|
|
n, err := strconv.Atoi(strings.TrimSpace(raw))
|
|
if err != nil || n <= last {
|
|
return o, fmt.Errorf("sizes must be strictly increasing positive integers: %q", raw)
|
|
}
|
|
o.sizes = append(o.sizes, n)
|
|
last = n
|
|
}
|
|
return o, nil
|
|
}
|