diff options
author | jasplin <qt-info@nokia.com> | 2011-04-26 15:55:05 +0200 |
---|---|---|
committer | jasplin <qt-info@nokia.com> | 2011-04-26 15:55:05 +0200 |
commit | 30f21cd291af000f2a6835d7f7d1d187c951814e (patch) | |
tree | f720b404f84738b7bcfa71729ca29aad2b451614 | |
parent | 66957dfb8b629c2bfecc83840aa2d0286de55f05 (diff) |
Fixed indexing bug in time series plot containing invalid results.
Selecting a snapshot in the time series plot did not have the
expected effect if certain other snapshots did not have a
valid median result (because all results were invalid or
missing altogether).
-rw-r--r-- | web/analysis/tsbmbody.js | 68 |
1 files changed, 41 insertions, 27 deletions
diff --git a/web/analysis/tsbmbody.js b/web/analysis/tsbmbody.js index 8706208..2901ebb 100644 --- a/web/analysis/tsbmbody.js +++ b/web/analysis/tsbmbody.js @@ -555,10 +555,12 @@ function createPlot( var minVal = null; var maxVal = null; - var tsValCoords = []; + var tsValidCoords = []; + var indexToValidIndex = []; var tsSampleSizeCoords = []; var tsNRSECoords = []; // NRSE = Normalized Relative Standard Error var tsNRSEVals = []; + var indexToNRSEIndex = []; var tsInvalidCoords = []; var tsZeroCoords = []; var isMissing = []; @@ -571,7 +573,8 @@ function createPlot( val = timeSeries[i][1]; if (val > 0) { - tsValCoords[tsValCoords.length] = [index, val]; + indexToValidIndex[i] = tsValidCoords.length; + tsValidCoords[tsValidCoords.length] = [index, val]; if (!minMaxValSet) { minVal = maxVal = val; minMaxValSet = true; @@ -585,11 +588,14 @@ function createPlot( tsSampleSizeCoords[tsSampleSizeCoords.length] = [index, sampleSize]; if (sampleSize > 1) { var nrse = timeSeries[i][3]; - if (val > 0) + if (val > 0) { + indexToNRSEIndex[i] = tsNRSEVals.length; tsNRSEVals[tsNRSEVals.length] = nrse; + } scaledNRSE = nrse * maxSampleSize; tsNRSECoords[tsNRSECoords.length] = [index, scaledNRSE]; } else if (val > 0) { + indexToNRSEIndex[i] = tsNRSEVals.length; tsNRSEVals[tsNRSEVals.length] = -1; } @@ -616,9 +622,13 @@ function createPlot( tsIndex = changes[i][0]; val = changes[i][1]; if (val > 1) { - goodChangeCoords[goodChangeCoords.length] = tsValCoords[tsIndex]; + goodChangeCoords[goodChangeCoords.length] = + tsValidCoords[indexToValidIndex[tsIndex]]; + } else { - badChangeCoords[badChangeCoords.length] = tsValCoords[tsIndex]; + badChangeCoords[badChangeCoords.length] = + tsValidCoords[indexToValidIndex[tsIndex]]; + } } @@ -741,7 +751,7 @@ function createPlot( fill: false }, shadowSize: 2, - data: tsValCoords + data: tsValidCoords }, { hoverable: false, @@ -797,23 +807,23 @@ function createPlot( prevHoverIndex = snIndex; var tsIndex = -1; // Time series index - for (tsIndex = 0; tsIndex < tsValCoords.length; ++tsIndex) { - if (tsValCoords[tsIndex][0] == snIndex) + for (tsIndex = 0; tsIndex < tsValidCoords.length; ++tsIndex) { + if (tsValidCoords[tsIndex][0] == snIndex) break; } - if (tsIndex == tsValCoords.length) + if (tsIndex == tsValidCoords.length) // The time series is missing the clicked snapshot: tsIndex = -1; plot.setHoveredSnapshot(snIndex, snIndex); plot.triggerRedrawOverlay(); - // $("#curr_sshot_sha1").text(snapshots[tsValCoords[tsIndex][0]][0]); - // $("#curr_sshot_median_obs").text(tsValCoords[tsIndex][1]); + // $("#curr_sshot_sha1").text(snapshots[tsValidCoords[tsIndex][0]][0]); + // $("#curr_sshot_median_obs").text(tsValidCoords[tsIndex][1]); // if (tsIndex > 0) { - // var val1 = tsValCoords[tsIndex - 1][1]; - // var val2 = tsValCoords[tsIndex][1]; + // var val1 = tsValidCoords[tsIndex - 1][1]; + // var val2 = tsValidCoords[tsIndex][1]; // if (lowerIsBetter) { // ratio = val1 / val2; // } else { @@ -822,8 +832,8 @@ function createPlot( // $("#base_res_median_obs").text(val1); // $("#curr_sshot_change").text(ratio); - // sha1 = snapshots[tsValCoords[tsIndex][0]][0]; - // sha1_prec = snapshots[tsValCoords[tsIndex - 1][0]][0]; + // sha1 = snapshots[tsValidCoords[tsIndex][0]][0]; + // sha1_prec = snapshots[tsValidCoords[tsIndex - 1][0]][0]; // fetchResultDetails2(benchmark, metric, sha1_prec, sha1); // } else { @@ -864,11 +874,11 @@ function createPlot( prevClickIndex = snIndex; var tsIndex = -1; // Time series index - for (tsIndex = 0; tsIndex < tsValCoords.length; ++tsIndex) { - if (tsValCoords[tsIndex][0] == snIndex) + for (tsIndex = 0; tsIndex < tsValidCoords.length; ++tsIndex) { + if (tsValidCoords[tsIndex][0] == snIndex) break; } - if (tsIndex == tsValCoords.length) + if (tsIndex == tsValidCoords.length) // The time series is missing the clicked snapshot: tsIndex = -1; @@ -889,7 +899,7 @@ function createPlot( if (tsIndex >= 0) { - $("#curr_sshot_median_obs").text(tsValCoords[tsIndex][1]); + $("#curr_sshot_median_obs").text(tsValidCoords[tsIndex][1]); var nrse = tsNRSEVals[tsIndex]; if (nrse >= 0) $("#curr_sshot_rse").text((nrse * 100).toFixed(2)); @@ -900,25 +910,29 @@ function createPlot( var i; var baseIndex = 0; + var validBaseIndex = 0; + var nrseBaseIndex = 0; for (i = 0; i < changes.length; ++i) { changeIndex = changes[i][0]; - if (tsIndex <= changeIndex) + if (tsIndex <= indexToValidIndex[changeIndex]) break; baseIndex = changeIndex; + validBaseIndex = indexToValidIndex[baseIndex]; + nrseBaseIndex = indexToNRSEIndex[baseIndex]; } - var baseVal = tsValCoords[baseIndex][1]; - var changeVal = tsValCoords[tsIndex][1]; + var baseVal = tsValidCoords[validBaseIndex][1]; + var changeVal = tsValidCoords[tsIndex][1]; if (lowerIsBetter) ratio = baseVal / changeVal; else ratio = changeVal / baseVal; - var baseTsIndex = tsValCoords[baseIndex][0]; + var baseTsIndex = tsValidCoords[validBaseIndex][0]; $("#base_res_sha1").text(snapshots[baseTsIndex][0]); $("#base_res_median_obs").text(baseVal); - var nrse = tsNRSEVals[baseIndex]; + var nrse = tsNRSEVals[nrseBaseIndex]; if (nrse >= 0) $("#base_res_rse").text((nrse * 100).toFixed(2)); else @@ -928,11 +942,11 @@ function createPlot( "color", (ratio > 1) ? "#0a0" : ((ratio < 1) ? "f00" : "000")); - var sha1 = snapshots[tsValCoords[tsIndex][0]][0]; - var sha1_prec = snapshots[tsValCoords[baseIndex][0]][0]; + var sha1 = snapshots[tsValidCoords[tsIndex][0]][0]; + var sha1_prec = snapshots[tsValidCoords[validBaseIndex][0]][0]; fetchResultDetails2(benchmark, metric, sha1_prec, sha1); } else { - var sha1 = snapshots[tsValCoords[tsIndex][0]][0]; + var sha1 = snapshots[tsValidCoords[tsIndex][0]][0]; fetchResultDetails2(benchmark, metric, "", sha1); } } |