Skip to content

Commit

Permalink
Real pages/sec calculation and output
Browse files Browse the repository at this point in the history
  • Loading branch information
Unbewohnte committed Jan 23, 2023
1 parent d4888da commit 5150edc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"unbewohnte/wecr/worker"
)

const version = "v0.2.2"
const version = "v0.2.3"

const (
defaultConfigFile string = "conf.json"
Expand Down Expand Up @@ -368,19 +368,20 @@ func main() {
// if logs are not used or are printed to the file - output a nice statistics message on the screen
if !conf.Logging.OutputLogs || (conf.Logging.OutputLogs && conf.Logging.LogsFile != "") {
go func() {
var lastPagesVisited uint64 = 0
fmt.Printf("\n")
for {
time.Sleep(time.Second)

timeSince := time.Since(workerPool.Stats.StartTime).Round(time.Second)

fmt.Fprintf(os.Stdout, "\r[%s] %d pages visited; %d pages saved; %d matches (%d pages/sec)",
timeSince.String(),
workerPool.Stats.PagesVisited,
workerPool.Stats.PagesSaved,
workerPool.Stats.MatchesFound,
workerPool.Stats.PagesVisited/uint64(timeSince.Seconds()),
workerPool.Stats.PagesVisited-lastPagesVisited,
)
lastPagesVisited = workerPool.Stats.PagesVisited
}
}()
}
Expand Down

0 comments on commit 5150edc

Please sign in to comment.