Skip to content

Commit 3a06515

Browse files
committed
update pbar
1 parent 79a1b5f commit 3a06515

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/par_quicksort.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -781,13 +781,15 @@ fn recurse<'a, T, F>(
781781
// Very short slices get sorted using insertion sort.
782782
if len <= MAX_INSERTION {
783783
insertion_sort(v, is_less);
784+
pbar.inc(len as u64);
784785
return;
785786
}
786787

787788
// If too many bad pivot choices were made, simply fall back to heapsort in order to
788789
// guarantee `O(n * log(n))` worst-case.
789790
if limit == 0 {
790791
heapsort(v, is_less);
792+
pbar.inc(len as u64);
791793
return;
792794
}
793795

@@ -807,6 +809,7 @@ fn recurse<'a, T, F>(
807809
// Try identifying several out-of-order elements and shifting them to correct
808810
// positions. If the slice ends up being completely sorted, we're done.
809811
if partial_insertion_sort(v, is_less) {
812+
pbar.inc(len as u64);
810813
return;
811814
}
812815
}
@@ -847,7 +850,6 @@ fn recurse<'a, T, F>(
847850
v = left;
848851
}
849852
} else {
850-
pbar.inc(1);
851853
// Sort the left and right half in parallel.
852854
rayon_core::join(
853855
|| recurse(left, is_less, pred, limit, pbar),
@@ -874,7 +876,8 @@ where
874876
// Limit the number of imbalanced partitions to `floor(log2(len)) + 1`.
875877
let limit = usize::BITS - v.len().leading_zeros();
876878
let pbar = if verbose {
877-
let p = ProgressBar::new((v.len() as f64 / 2000.0).ceil() as u64);
879+
// increment progression after each MAX_SEQUENTIAL length slice is sorted
880+
let p = ProgressBar::new(v.len() as u64);
878881
p.set_style(
879882
ProgressStyle::with_template(
880883
"{elapsed} elapsed (estimated duration {duration}) {bar:80}",

0 commit comments

Comments
 (0)