From 7660e9de645be6f4506cc29bd961ea131fc626e7 Mon Sep 17 00:00:00 2001 From: Ryo Nakao Date: Sun, 25 Oct 2020 10:07:30 +0900 Subject: [PATCH] Use buffered channel for appending chart values (#79) --- gui/drawer.go | 7 +++---- gui/gui.go | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gui/drawer.go b/gui/drawer.go index b8ebd86..a4934e9 100644 --- a/gui/drawer.go +++ b/gui/drawer.go @@ -26,13 +26,12 @@ type drawer struct { metricsCh chan *attacker.Metrics doneCh chan struct{} - chartValues values - metrics *attacker.Metrics - // aims to avoid to perform multiple `appendChartValues`. chartDrawing *atomic.Bool - mu sync.RWMutex + mu sync.RWMutex + chartValues values + metrics *attacker.Metrics } type values struct { diff --git a/gui/gui.go b/gui/gui.go index ce5e02b..660f3fd 100644 --- a/gui/gui.go +++ b/gui/gui.go @@ -68,7 +68,7 @@ func run(t terminalapi.Terminal, r runner, targetURL string, opts *attacker.Opti d := &drawer{ widgets: w, gridOpts: gridOpts, - chartCh: make(chan *attacker.Result), + chartCh: make(chan *attacker.Result, 10000), gaugeCh: make(chan struct{}), metricsCh: make(chan *attacker.Metrics), chartDrawing: atomic.NewBool(false),