|
8 | 8 | "strconv"
|
9 | 9 | "strings"
|
10 | 10 | "time"
|
| 11 | + "unicode" |
11 | 12 | )
|
12 | 13 |
|
13 | 14 | const version = "0.0"
|
@@ -53,15 +54,18 @@ func main() {
|
53 | 54 | flag.Var(&app.listeners, "listeners", "comma-separated list of listen addresses\nyou may prepend an optional host to every port: [host]:port")
|
54 | 55 | flag.StringVar(&app.defaultPort, "defaultPort", ":8080", "default port")
|
55 | 56 | flag.IntVar(&app.connections, "connections", 1, "number of parallel connections")
|
56 |
| - flag.StringVar(&app.reportInterval, "reportInterval", "2s", "periodic report interval") |
57 |
| - flag.StringVar(&app.totalDuration, "totalDuration", "10s", "test total duration") |
| 57 | + flag.StringVar(&app.reportInterval, "reportInterval", "2s", "periodic report interval\nunspecified time unit defaults to second") |
| 58 | + flag.StringVar(&app.totalDuration, "totalDuration", "10s", "test total duration\nunspecified time unit defaults to second") |
58 | 59 | flag.IntVar(&app.opt.ReadSize, "readSize", 20000, "read buffer size in bytes")
|
59 | 60 | flag.IntVar(&app.opt.WriteSize, "writeSize", 20000, "write buffer size in bytes")
|
60 | 61 | flag.BoolVar(&app.passiveClient, "passiveClient", false, "suppress client writes")
|
61 | 62 | flag.BoolVar(&app.opt.PassiveServer, "passiveServer", false, "suppress server writes")
|
62 | 63 |
|
63 | 64 | flag.Parse()
|
64 | 65 |
|
| 66 | + app.reportInterval = defaultTimeUnit(app.reportInterval) |
| 67 | + app.totalDuration = defaultTimeUnit(app.totalDuration) |
| 68 | + |
65 | 69 | var errInterval error
|
66 | 70 | app.opt.ReportInterval, errInterval = time.ParseDuration(app.reportInterval)
|
67 | 71 | if errInterval != nil {
|
@@ -92,3 +96,14 @@ func main() {
|
92 | 96 | log.Printf("client mode")
|
93 | 97 | open(&app)
|
94 | 98 | }
|
| 99 | + |
| 100 | +// append "s" (second) to time string |
| 101 | +func defaultTimeUnit(s string) string { |
| 102 | + if len(s) < 1 { |
| 103 | + return s |
| 104 | + } |
| 105 | + if unicode.IsDigit(rune(s[len(s)-1])) { |
| 106 | + return s + "s" |
| 107 | + } |
| 108 | + return s |
| 109 | +} |
0 commit comments