Skip to content

Commit 6998f5f

Browse files
author
Dmytro Ukhlov
committed
Fix "Zeno’s paradox" like logic of the progress calculation
1 parent 213efed commit 6998f5f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

core/src/main/java/jenkins/widgets/RunListProgressiveRendering.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public abstract class RunListProgressiveRendering extends ProgressiveRendering {
4646
* The first increment will be sized as if this many runs will be in the total,
4747
* but then like Zeno’s paradox we will never seem to finish until we actually do.
4848
*/
49-
private static final double MAX_LIKELY_RUNS = 20;
49+
private static final double MAX_LIKELY_RUNS = 20; // if (MAX_LIKELY_RUNS / 2) runs are processed, progress is 0.5
5050
private final List<JSONObject> results = new ArrayList<>();
5151
private Iterable<? extends Run<?, ?>> builds;
5252

@@ -56,7 +56,7 @@ public void setBuilds(Iterable<? extends Run<?, ?>> builds) {
5656
}
5757

5858
@Override protected void compute() throws Exception {
59-
double decay = 1;
59+
int processed = 0;
6060
for (Run<?, ?> build : builds) {
6161
if (canceled()) {
6262
return;
@@ -66,8 +66,8 @@ public void setBuilds(Iterable<? extends Run<?, ?>> builds) {
6666
synchronized (this) {
6767
results.add(element);
6868
}
69-
decay *= 1 - 1 / MAX_LIKELY_RUNS;
70-
progress(1 - decay);
69+
processed++;
70+
progress(processed / (processed + MAX_LIKELY_RUNS / 2.0));
7171
}
7272
}
7373

0 commit comments

Comments
 (0)