From 20dbfa1b1acefc10694fe0cdf467f9c65fb62550 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Thu, 30 Mar 2023 16:30:15 +0200 Subject: Minor renaming and re-ordering --- main.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 072924a..a6ee613 100644 --- a/main.go +++ b/main.go @@ -234,9 +234,9 @@ func workGenerator(ctx context.Context, opts options.Options, fp *os.File, quest } } - // initialize ticker - ticker := time.NewTicker(opts.MetricsInterval) - defer ticker.Stop() + // initialize metrics + metrics := time.NewTicker(opts.MetricsInterval) + defer metrics.Stop() startTime := time.Now().Unix() latestTime := startTime latestCount := opts.StartLineInclusive @@ -263,7 +263,10 @@ func workGenerator(ctx context.Context, opts options.Options, fp *os.File, quest select { case <-ctx.Done(): return nextLine, false - case <-ticker.C: + case questionCh <- qna.Question{Domain: scanner.Text()}: + nextLine++ + readCount++ + case <-metrics.C: now := time.Now().Unix() log.Printf("INFO: currently %.1f sites/s, %.1f sites/s since start, at line %d\n", float64(nextLine-latestCount)/float64(now-latestTime), @@ -273,9 +276,6 @@ func workGenerator(ctx context.Context, opts options.Options, fp *os.File, quest latestCount = nextLine latestTime = now - case questionCh <- qna.Question{Domain: scanner.Text()}: - nextLine++ - readCount++ } } -- cgit v1.2.3