aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@rgdd.se>2023-03-30 16:30:15 +0200
committerRasmus Dahlberg <rasmus@rgdd.se>2023-03-30 16:30:15 +0200
commit20dbfa1b1acefc10694fe0cdf467f9c65fb62550 (patch)
tree9d91cdc4ad2f1cabb3b648e24e9f81d044361d8c
parent4a36fbdc9972c5b6101d6f3bc9bd0a77c8c83fd4 (diff)
Minor renaming and re-ordering
-rw-r--r--main.go14
1 files 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++
}
}