diff options
author | 2016-06-21 08:44:15 +0000 | |
---|---|---|
committer | 2016-06-21 09:59:33 +0000 | |
commit | cd211eebe4a2eb776ecf7ee65cc5954aa1110e48 (patch) | |
tree | c3f9359bc3c877c1b361acce402209df56f47d0e /src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java | |
parent | 7ec10f916afa89975a3451b2083591d9191cd615 (diff) |
Add an option for the number of actions shown in the experimental UI
Currently, the experimental UI always shows the 3 oldest, still running actions.
While this seems a reasonable default, some users requested to be able to change
the number of actions shown. Hence replace the hard-coded value by a flag.
While there, also fix an off-by-one error in deciding when to put the ellipsis
symbol.
--
Change-Id: I037d208360fa1d3f100c99ab1ab1f5fc140138ac
Reviewed-on: https://bazel-review.googlesource.com/#/c/3811
MOS_MIGRATED_REVID=125427168
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java index f5fb46d1bb..5343bfa19e 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java @@ -48,12 +48,13 @@ import java.util.TreeSet; */ class ExperimentalStateTracker { - static final int SAMPLE_SIZE = 3; static final long SHOW_TIME_THRESHOLD_SECONDS = 3; static final String ELLIPSIS = "..."; static final int NANOS_PER_SECOND = 1000000000; + private int sampleSize = 3; + private String status; private String additionalMessage; @@ -101,6 +102,13 @@ class ExperimentalStateTracker { this(clock, 0); } + /** + * Set the maximal number of actions shown in the progress bar. + */ + void setSampleSize(int sampleSize) { + this.sampleSize = sampleSize; + } + void buildStarted(BuildStartingEvent event) { status = "Loading"; additionalMessage = ""; @@ -368,10 +376,11 @@ class ExperimentalStateTracker { continue; } count++; - if (count > SAMPLE_SIZE) { + if (count > sampleSize) { + totalCount--; break; } - int width = (count >= SAMPLE_SIZE && count < actionCount) ? targetWidth - 8 : targetWidth - 4; + int width = (count >= sampleSize && count < actionCount) ? targetWidth - 8 : targetWidth - 4; terminalWriter.newline().append(" " + describeAction(action, nanoTime, width, toSkip)); } if (totalCount < actionCount) { |