Skip to content

Commit

Permalink
Better display timing for steps/blocks with under 1 ms or no timing
Browse files Browse the repository at this point in the history
  • Loading branch information
svanoort committed Sep 16, 2016
1 parent 9c38bbf commit 5db71dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Expand Up @@ -109,6 +109,7 @@ private Row buildForwardReferences(Map<FlowNode, Row> rows) {

if (r.hasStartTime && sr.hasStartTime) { // Block timing is based on the start-to-end times
sr.durationMillis = (r.startTimeMillis-sr.startTimeMillis);
sr.hasTiming = true;
}

assert sr.endNode==null : "start/end mapping should be 1:1";
Expand Down Expand Up @@ -215,10 +216,12 @@ private List<Row> order(Row r) {
if (newRow.durationMillis == 0 && newRow.hasStartTime) {
if (newRow.node instanceof BlockStartNode && newRow.endNode == null) { // Block is running & incomplete
newRow.durationMillis = System.currentTimeMillis()-newRow.startTimeMillis;
newRow.hasTiming = true;
} else {
Row nextRow = newRow.firstGraphChild;
if (nextRow.hasStartTime) {
newRow.durationMillis = nextRow.startTimeMillis-newRow.startTimeMillis;
newRow.hasTiming = true;
}
}
}
Expand All @@ -232,6 +235,7 @@ public static class Row {
private long durationMillis = 0L;
private final long startTimeMillis;
private final boolean hasStartTime;
private boolean hasTiming = false;

/**
* We collapse {@link BlockStartNode} and {@link BlockEndNode} into one row.
Expand All @@ -258,6 +262,7 @@ private Row(FlowNode node) {
this.hasStartTime = true;
if (node.isRunning()) {
this.durationMillis=System.currentTimeMillis()-this.startTimeMillis;
this.hasTiming = true;
}
} else {
this.startTimeMillis = 0L;
Expand Down Expand Up @@ -290,10 +295,14 @@ public long getDurationMillis() {
}

public String getDurationString() {
if (this.durationMillis == 0) {
return "";
if (!this.hasTiming) {
return "no timing";
} else {
return Util.getTimeSpanString(this.durationMillis);
if (this.durationMillis == 0) {
return "<1 ms";
} else {
return Util.getTimeSpanString(this.durationMillis);
}
}
}

Expand Down Expand Up @@ -326,6 +335,7 @@ void addGraphSibling(Row r) {

if (s.hasStartTime && r.hasStartTime) {
s.durationMillis = (r.startTimeMillis-s.startTimeMillis);
s.hasTiming = true;
}
}

Expand All @@ -350,6 +360,7 @@ void addTreeSibling(Row r) {

if (s.hasStartTime && r.hasStartTime) { // Store timing
s.durationMillis = (r.startTimeMillis-s.startTimeMillis);
s.hasTiming = true;
}
}
}
Expand Down
Expand Up @@ -48,9 +48,7 @@
<j:set var="timeType" value="${row.isStart() ? 'in block' : 'in self'}"></j:set>
<td style="padding-left: ${row.treeDepth*20+5}px" tooltip="ID: ${node.id}${exec_state}">
<a href="${rootURL}/${node.url}">
${row.displayName}
<j:if test="${row.durationMillis > 0}"> - (${row.durationString} ${timeType})
</j:if>
${row.displayName} - (${row.durationString} ${timeType})
</a>
</td>
<j:forEach var="column" items="${columns}">
Expand Down

0 comments on commit 5db71dd

Please sign in to comment.