Skip to content

Commit

Permalink
Made progress.Bar.Update and the worker pool OnComplete func use the …
Browse files Browse the repository at this point in the history
…same signature.
  • Loading branch information
Martin Bruse committed Apr 19, 2024
1 parent f1c7b57 commit ccc1e00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions go/dataset/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (s Setup) getOptimizeComparisons() (map[string]comparisonSlice, error) {
pool := &worker.Pool[prepareResult]{
Workers: safeInt(s.MaxWorkers),
OnComplete: func(submitted, completed int) {
bar.Update(completed, submitted)
bar.Update(submitted, completed)
},
}
for _, loopDatasetDir := range datasetDirs {
Expand Down Expand Up @@ -256,7 +256,7 @@ func (s Setup) optimize() error {
pool := &worker.Pool[compareResult]{
Workers: safeInt(s.MaxWorkers),
OnComplete: func(submitted, completed int) {
bar.Update(completed, submitted)
bar.Update(submitted, completed)
},
}

Expand Down Expand Up @@ -462,7 +462,7 @@ func (s Setup) Run() error {
}
bar := progress.New(fmt.Sprintf("Calculating for %v references", len(data.References)))
result, err := data.Calculate(metrics, func(submitted, completed int) {
bar.Update(completed, submitted)
bar.Update(submitted, completed)
}, safeInt(s.MaxWorkers), safeString(s.ProgressDirectory))
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions go/progress/bar.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ type Bar struct {

// AddCompleted adds completed tasks to the bar and renders it.
func (b *Bar) AddCompleted(num int) {
b.Update(b.completed+num, b.total)
b.Update(b.total, b.completed+num)
}

// Update update completed and total tasks to the bar and updates it.
func (b *Bar) Update(completed, total int) {
func (b *Bar) Update(total, completed int) {
prefix := fmt.Sprintf("%s, %d/%d ", b.name, completed, total)

now := time.Now()
Expand Down

0 comments on commit ccc1e00

Please sign in to comment.