diff --git a/cmd/radiobench/radiobench.go b/cmd/radiobench/radiobench.go index 3ace6c6ea37122e891bbcafabed0606b9996140d..abf3d148581b49d9d7a27aa814632695f4893325 100644 --- a/cmd/radiobench/radiobench.go +++ b/cmd/radiobench/radiobench.go @@ -13,9 +13,8 @@ import ( ) var ( - numConns int - - stats = &Stats{} + numConns = flag.Int("n", 3, "number of parallel connections") + stats = NewStats() retryTime = 2 * time.Second ) @@ -26,6 +25,12 @@ type Stats struct { lock sync.Mutex } +func NewStats() *Stats { + return &Stats{ + HttpStatus: make(map[int]int), + } +} + func (s *Stats) HttpError(resp *http.Response) { s.lock.Lock() defer s.lock.Unlock() @@ -50,11 +55,6 @@ func (s *Stats) Dump() { log.Printf("errs=%d http_errs=%d http_status=%v", s.Errors, s.HttpErrors, s.HttpStatus) } -func init() { - flag.IntVar(&numConns, "n", 3, "number of parallel connections") - flag.IntVar(&numConns, "num-clients", 3, "number of parallel connections") -} - func readstream(id int, streamUrl string) error { resp, err := http.Get(streamUrl) if err != nil { @@ -135,7 +135,7 @@ func main() { go dumpStats() var wg sync.WaitGroup - for i := 0; i < numConns; i++ { + for i := 0; i < *numConns; i++ { wg.Add(1) go func(id int) { worker(id, streamUrl)