diff options
| author | Paul Buetow <git@mx.buetow.org> | 2020-12-26 10:48:51 +0000 |
|---|---|---|
| committer | Paul Buetow <git@mx.buetow.org> | 2020-12-26 10:48:51 +0000 |
| commit | ab676c2b484225ed22765b23d8f0545088ecd610 (patch) | |
| tree | 5292e21339fef551f19e8fdd90beeb35d676381d /internal/clients/stats.go | |
| parent | b4db37d8cbae8f0c3dec289b2e1b0cfe83731415 (diff) | |
code cleanup and minor refactorings
Diffstat (limited to 'internal/clients/stats.go')
| -rw-r--r-- | internal/clients/stats.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/internal/clients/stats.go b/internal/clients/stats.go index 17343b5..2ec6f22 100644 --- a/internal/clients/stats.go +++ b/internal/clients/stats.go @@ -45,7 +45,7 @@ func (s *stats) Start(ctx context.Context, throttleCh <-chan struct{}, statsCh < case message := <-statsCh: messages = append(messages, message) force = true - case <-time.After(time.Second * 10): + case <-time.After(time.Second * 3): case <-ctx.Done(): return } @@ -63,7 +63,7 @@ func (s *stats) Start(ctx context.Context, throttleCh <-chan struct{}, statsCh < switch force { case true: messages = append(messages, fmt.Sprintf("Connection stats: %s", stats)) - s.printStatsOnInterrupt(messages) + s.printStatsDueInterrupt(messages) default: logger.Info(stats) } @@ -75,7 +75,7 @@ func (s *stats) Start(ctx context.Context, throttleCh <-chan struct{}, statsCh < } } -func (s *stats) printStatsOnInterrupt(messages []string) { +func (s *stats) printStatsDueInterrupt(messages []string) { logger.Pause() for _, message := range messages { fmt.Println(fmt.Sprintf(" %s", message)) @@ -107,5 +107,6 @@ func percentOf(total float64, value float64) float64 { if total == 0 || total == value { return 100 } + return value / (total / 100.0) } |
