Skip to content

Commit

Permalink
Better statistics - part 2 #30
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaakko Heusala committed Oct 20, 2024
1 parent 0a07892 commit c06644c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/workers/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,17 @@ func (m *WorkerPool[T]) Start(workers int, f func(T)) error {
diffJobsWaiting := int64(currentJobsWaiting) - prevJobsWaiting
diffJobsProcessing := int64(currentJobsProcessing) - prevJobsProcessing

jobsPublishedSecond := float64(diffPublishedCount) / float64(diffTime) / 1000
jobsStartedSecond := float64(diffStartedCount) / float64(diffTime) / 1000
jobsFinishedSecond := float64(diffFinishedCount) / float64(diffTime) / 1000
jobsPublishedSecond := float64(diffPublishedCount) / float64(diffTime)
jobsStartedSecond := float64(diffStartedCount) / float64(diffTime)
jobsFinishedSecond := float64(diffFinishedCount) / float64(diffTime)

if diffPublishedCount != 0 || diffStartedCount != 0 || diffFinishedCount != 0 {
log.Infof("Pool active: Published=%d (%f/s), Started=%d (%f/s), Finished=%d (%f/s), Queue=%d (%d), Processing=%d (%d)",
diffPublishedCount, jobsPublishedSecond, diffStartedCount, jobsStartedSecond, diffFinishedCount, jobsFinishedSecond, diffJobsWaiting, currentJobsWaiting, diffJobsProcessing, currentJobsProcessing)
log.Infof("Pool active: Published=%d (%f/ms), Started=%d (%f/ms), Finished=%d (%f/ms), Queue=%d (%d), Processing=%d (%d)",
diffPublishedCount, jobsPublishedSecond, diffStartedCount, jobsStartedSecond, diffFinishedCount, jobsFinishedSecond, currentJobsWaiting, diffJobsWaiting, currentJobsProcessing, diffJobsProcessing)
} else {
log.Debugf(
"Pool passive: Published=%d (%f/s), Started=%d (%f/s), Finished=%d (%f/s), Queue=%d (%d), Processing=%d (%d)",
diffPublishedCount, jobsPublishedSecond, diffStartedCount, jobsStartedSecond, diffFinishedCount, jobsFinishedSecond, diffJobsWaiting, currentJobsWaiting, diffJobsProcessing, currentJobsProcessing)
"Pool passive: Published=%d (%f/ms), Started=%d (%f/ms), Finished=%d (%f/ms), Queue=%d (%d), Processing=%d (%d)",
diffPublishedCount, jobsPublishedSecond, diffStartedCount, jobsStartedSecond, diffFinishedCount, jobsFinishedSecond, currentJobsWaiting, diffJobsWaiting, currentJobsProcessing, diffJobsProcessing)
}

prevPublishedCount = m.PublishedJobs()
Expand Down

0 comments on commit c06644c

Please sign in to comment.