Skip to content

Commit cccf637

Browse files
authored
Merge pull request tobami#233 from smarr/fixes/timeline-freeze-on-missing-data
Ensure missing data points don’t lead to infinite loop
2 parents 7b5423a + 48052fc commit cccf637

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

codespeed/static/js/timeline.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,20 @@ function getHighlighterConfig(median) {
9595
}
9696
}
9797

98+
function determineSignificantDigits(value, digits) {
99+
var val = Math.abs(value);
100+
101+
while (val < 1) {
102+
val *= 10;
103+
digits++;
104+
}
105+
return digits;
106+
}
107+
98108
function renderPlot(data) {
99109
var plotdata = [],
100110
series = [],
101-
lastvalues = [];//hopefully the smallest values for determining significant digits.
111+
smallestValue = Number.MAX_SAFE_INTEGER; // hopefully the smallest values for determining significant digits.
102112
seriesindex = [];
103113
var hiddenSeries = 0;
104114
var median = data['data_type'] === 'M';
@@ -154,17 +164,17 @@ function renderPlot(data) {
154164
series.push(seriesConfig);
155165
seriesindex.push(exe_id);
156166
plotdata.push(data.branches[branch][exe_id]);
157-
lastvalues.push(data.branches[branch][exe_id][0][1]);
158-
}
159-
//determine significant digits
160-
var digits = 2;
161-
var value = Math.min.apply( Math, lastvalues );
162-
if (value !== 0) {
163-
while( value < 1 ) {
164-
value *= 10;
165-
digits++;
167+
168+
// determine smallest non-negative value in lastvalues
169+
// (missing values can be represented as -1)
170+
var val = data.branches[branch][exe_id][0][1];
171+
if (val > 0 && val < smallestValue) {
172+
smallestValue = val;
166173
}
167174
}
175+
176+
var digits = determineSignificantDigits(smallestValue, 2);
177+
168178
$("#plotgrid").html('<div id="plot"></div><div id="plotdescription"></div>');
169179

170180
if (data.benchmark_description) {

0 commit comments

Comments
 (0)