<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[179965] trunk/Websites/perf.webkit.org</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/179965">179965</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2015-02-11 14:56:31 -0800 (Wed, 11 Feb 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>New perf dashboard shows too much space around interesting data points
https://bugs.webkit.org/show_bug.cgi?id=141487

Reviewed by Chris Dumez.

Revise the y-axis range adjustment algorithm in <a href="http://trac.webkit.org/projects/webkit/changeset/179913">r179913</a>. Instead of showing the entire moving average,
show the current time series excluding points in the series outside the moving average envelope.

* public/v2/app.js:
(App.Pane._computeChartData): Don't deal with missing moving average or enveloping strategy here.
(App.Pane._computeMovingAverageAndOutliers): Set isOutliner to true on all data points in the current
time series if the point lies outside the moving average envelope. Don't expose the moving average or
the envelope computed for this purpose if they're not set by the user.

* public/v2/data.js:
(TimeSeries.prototype.minMaxForTimeRange): Takes a boolean argument, ignoreOutlier. When the flag is set
to true, min/max computation will ignore any point in the series with non-falsy &quot;isOutliner&quot; property.

* public/v2/interactive-chart.js:
(App.InteractiveChartComponent._constructGraphIfPossible): Unsupport hideMovingAverage and hideEnvelope.
(App.InteractiveChartComponent._computeYAxisDomain): Removed the commented out code. Also moved the code
to deal with showFullYAxis here.
(App.InteractiveChartComponent._minMaxForAllTimeSeries): Rewrote the code. Takes ignoreOutliners as an
argument instead of directly inspecting showFullYAxis.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebsitesperfwebkitorgChangeLog">trunk/Websites/perf.webkit.org/ChangeLog</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv2appjs">trunk/Websites/perf.webkit.org/public/v2/app.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv2datajs">trunk/Websites/perf.webkit.org/public/v2/data.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv2interactivechartjs">trunk/Websites/perf.webkit.org/public/v2/interactive-chart.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebsitesperfwebkitorgChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/ChangeLog (179964 => 179965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/ChangeLog        2015-02-11 22:51:11 UTC (rev 179964)
+++ trunk/Websites/perf.webkit.org/ChangeLog        2015-02-11 22:56:31 UTC (rev 179965)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2015-02-11  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        New perf dashboard shows too much space around interesting data points
+        https://bugs.webkit.org/show_bug.cgi?id=141487
+
+        Reviewed by Chris Dumez.
+
+        Revise the y-axis range adjustment algorithm in r179913. Instead of showing the entire moving average,
+        show the current time series excluding points in the series outside the moving average envelope.
+
+        * public/v2/app.js:
+        (App.Pane._computeChartData): Don't deal with missing moving average or enveloping strategy here.
+        (App.Pane._computeMovingAverageAndOutliers): Set isOutliner to true on all data points in the current
+        time series if the point lies outside the moving average envelope. Don't expose the moving average or
+        the envelope computed for this purpose if they're not set by the user.
+
+        * public/v2/data.js:
+        (TimeSeries.prototype.minMaxForTimeRange): Takes a boolean argument, ignoreOutlier. When the flag is set
+        to true, min/max computation will ignore any point in the series with non-falsy &quot;isOutliner&quot; property.
+
+        * public/v2/interactive-chart.js:
+        (App.InteractiveChartComponent._constructGraphIfPossible): Unsupport hideMovingAverage and hideEnvelope.
+        (App.InteractiveChartComponent._computeYAxisDomain): Removed the commented out code. Also moved the code
+        to deal with showFullYAxis here.
+        (App.InteractiveChartComponent._minMaxForAllTimeSeries): Rewrote the code. Takes ignoreOutliners as an
+        argument instead of directly inspecting showFullYAxis.
+
</ins><span class="cx"> 2015-02-10  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         New perf dashboard shouldn't always show outliners
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv2appjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v2/app.js (179964 => 179965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v2/app.js        2015-02-11 22:51:11 UTC (rev 179964)
+++ trunk/Websites/perf.webkit.org/public/v2/app.js        2015-02-11 22:56:31 UTC (rev 179965)
</span><span class="lines">@@ -484,38 +484,44 @@
</span><span class="cx">         var envelopingStrategy = this.get('chosenEnvelopingStrategy');
</span><span class="cx">         this._updateStrategyConfigIfNeeded(envelopingStrategy, 'envelopingConfig');
</span><span class="cx"> 
</span><del>-        if (!movingAverageStrategy || !movingAverageStrategy.execute) {
-            movingAverageStrategy = Statistics.MovingAverageStrategies[0];
-            chartData.hideMovingAverage = true;
-        }
-        if (!envelopingStrategy || !envelopingStrategy.execute) {
-            envelopingStrategy = Statistics.EnvelopingStrategies[0];
-            chartData.hideEnvelope = true;
-        }
</del><ins>+        chartData.movingAverage = this._computeMovingAverageAndOutliers(chartData, movingAverageStrategy, envelopingStrategy);
</ins><span class="cx"> 
</span><del>-        chartData.movingAverage = this._computeMovingAverage(chartData, movingAverageStrategy, envelopingStrategy);
-
</del><span class="cx">         this.set('chartData', chartData);
</span><span class="cx">     }.observes('chosenMovingAverageStrategy', 'chosenMovingAverageStrategy.parameterList.@each.value',
</span><span class="cx">         'chosenEnvelopingStrategy', 'chosenEnvelopingStrategy.parameterList.@each.value'),
</span><del>-    _computeMovingAverage: function (chartData, movingAverageStrategy, envelopingStrategy)
</del><ins>+    _computeMovingAverageAndOutliers: function (chartData, movingAverageStrategy, envelopingStrategy)
</ins><span class="cx">     {
</span><span class="cx">         var currentTimeSeriesData = chartData.current.series();
</span><del>-        var movingAverageValues = this._executeStrategy(movingAverageStrategy, currentTimeSeriesData);
</del><ins>+        var movingAverageIsSetByUser = movingAverageStrategy &amp;&amp; movingAverageStrategy.execute;
+        var movingAverageValues = this._executeStrategy(
+            movingAverageIsSetByUser ? movingAverageStrategy : Statistics.MovingAverageStrategies[0], currentTimeSeriesData);
</ins><span class="cx">         if (!movingAverageValues)
</span><span class="cx">             return null;
</span><span class="cx"> 
</span><del>-        var envelopeDelta = this._executeStrategy(envelopingStrategy, currentTimeSeriesData, [movingAverageValues]);
</del><ins>+        var envelopeIsSetByUser = envelopingStrategy &amp;&amp; envelopingStrategy.execute;
+        var envelopeDelta = this._executeStrategy(envelopeIsSetByUser ? envelopingStrategy : Statistics.EnvelopingStrategies[0],
+            currentTimeSeriesData, [movingAverageValues]);
</ins><span class="cx"> 
</span><del>-        return new TimeSeries(currentTimeSeriesData.map(function (point, index) {
-            var value = movingAverageValues[index];
-            return {
-                measurement: point.measurement,
-                time: point.time,
-                value: value,
-                interval: envelopeDelta !== null ? [value - envelopeDelta, value + envelopeDelta] : null,
-            }
-        }));
</del><ins>+        for (var i = 0; i &lt; currentTimeSeriesData.length; i++) {
+            var currentValue = currentTimeSeriesData[i].value;
+            var movingAverageValue = movingAverageValues[i];
+            if (currentValue &lt; movingAverageValue - envelopeDelta || movingAverageValue + envelopeDelta &lt; currentValue)
+                currentTimeSeriesData[i].isOutlier = true;
+        }
+        if (!envelopeIsSetByUser)
+            envelopeDelta = null;
+
+        if (movingAverageIsSetByUser) {
+            return new TimeSeries(currentTimeSeriesData.map(function (point, index) {
+                var value = movingAverageValues[index];
+                return {
+                    measurement: point.measurement,
+                    time: point.time,
+                    value: value,
+                    interval: envelopeDelta !== null ? [value - envelopeDelta, value + envelopeDelta] : null,
+                }
+            }));            
+        }
</ins><span class="cx">     },
</span><span class="cx">     _executeStrategy: function (strategy, currentTimeSeriesData, additionalArguments)
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv2datajs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v2/data.js (179964 => 179965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v2/data.js        2015-02-11 22:51:11 UTC (rev 179964)
+++ trunk/Websites/perf.webkit.org/public/v2/data.js        2015-02-11 22:56:31 UTC (rev 179965)
</span><span class="lines">@@ -372,7 +372,7 @@
</span><span class="cx">     return this._series.slice(startPoint.seriesIndex, endPoint.seriesIndex + 1);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TimeSeries.prototype.minMaxForTimeRange = function (startTime, endTime)
</del><ins>+TimeSeries.prototype.minMaxForTimeRange = function (startTime, endTime, ignoreOutlier)
</ins><span class="cx"> {
</span><span class="cx">     var data = this._series;
</span><span class="cx">     var i = 0;
</span><span class="lines">@@ -389,6 +389,8 @@
</span><span class="cx">     var max = Number.MIN_VALUE;
</span><span class="cx">     for (; i &lt; data.length; i++) {
</span><span class="cx">         var point = data[i];
</span><ins>+        if (point.isOutlier &amp;&amp; ignoreOutlier)
+            continue;
</ins><span class="cx">         var currentMin = point.interval ? point.interval[0] : point.value;
</span><span class="cx">         var currentMax = point.interval ? point.interval[1] : point.value;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv2interactivechartjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v2/interactive-chart.js (179964 => 179965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v2/interactive-chart.js        2015-02-11 22:51:11 UTC (rev 179964)
+++ trunk/Websites/perf.webkit.org/public/v2/interactive-chart.js        2015-02-11 22:56:31 UTC (rev 179965)
</span><span class="lines">@@ -128,7 +128,7 @@
</span><span class="cx">                 .attr(&quot;class&quot;, &quot;target&quot;));
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        var movingAverageIsVisible = this._movingAverageTimeSeries &amp;&amp; !chartData.hideMovingAverage;
</del><ins>+        var movingAverageIsVisible = this._movingAverageTimeSeries;
</ins><span class="cx">         var foregroundClass = movingAverageIsVisible ? '' : ' foreground';
</span><span class="cx">         this._areas.push(this._clippedContainer
</span><span class="cx">             .append(&quot;path&quot;)
</span><span class="lines">@@ -153,12 +153,10 @@
</span><span class="cx">                 .datum(this._movingAverageTimeSeries.series())
</span><span class="cx">                 .attr(&quot;class&quot;, &quot;movingAverage&quot;));
</span><span class="cx"> 
</span><del>-            if (!chartData.hideEnvelope) {
-                this._areas.push(this._clippedContainer
-                    .append(&quot;path&quot;)
-                    .datum(this._movingAverageTimeSeries.series())
-                    .attr(&quot;class&quot;, &quot;envelope&quot;));
-            }
</del><ins>+            this._areas.push(this._clippedContainer
+                .append(&quot;path&quot;)
+                .datum(this._movingAverageTimeSeries.series())
+                .attr(&quot;class&quot;, &quot;envelope&quot;));
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (isInteractive) {
</span><span class="lines">@@ -336,33 +334,33 @@
</span><span class="cx">     },
</span><span class="cx">     _computeYAxisDomain: function (startTime, endTime)
</span><span class="cx">     {
</span><del>-        var range = this._minMaxForAllTimeSeries(startTime, endTime);
</del><ins>+        var shouldShowFullYAxis = this.get('showFullYAxis');
+        var range = this._minMaxForAllTimeSeries(startTime, endTime, !shouldShowFullYAxis);
</ins><span class="cx">         var min = range[0];
</span><span class="cx">         var max = range[1];
</span><span class="cx">         if (max &lt; min)
</span><span class="cx">             min = max = 0;
</span><ins>+        else if (shouldShowFullYAxis)
+            min = Math.min(min, 0);
</ins><span class="cx">         var diff = max - min;
</span><span class="cx">         var margin = diff * 0.05;
</span><span class="cx"> 
</span><span class="cx">         yExtent = [min - margin, max + margin];
</span><del>-//        if (yMin !== undefined)
-//            yExtent[0] = parseInt(yMin);
</del><span class="cx">         return yExtent;
</span><span class="cx">     },
</span><del>-    _minMaxForAllTimeSeries: function (startTime, endTime)
</del><ins>+    _minMaxForAllTimeSeries: function (startTime, endTime, ignoreOutliners)
</ins><span class="cx">     {
</span><del>-        var shouldShowFullYAxis = this.get('showFullYAxis');
-        var mainTimeSeries = this._movingAverageTimeSeries &amp;&amp; !shouldShowFullYAxis ? this._movingAverageTimeSeries : this._currentTimeSeries;
-        var currentRange = mainTimeSeries.minMaxForTimeRange(startTime, endTime);
-        if (shouldShowFullYAxis)
-            currentRange[0] = Math.min(0, currentRange[0]);
-
-        var baselineRange = this._baselineTimeSeries ? this._baselineTimeSeries.minMaxForTimeRange(startTime, endTime) : [Number.MAX_VALUE, Number.MIN_VALUE];
-        var targetRange = this._targetTimeSeries ? this._targetTimeSeries.minMaxForTimeRange(startTime, endTime) : [Number.MAX_VALUE, Number.MIN_VALUE];
-        return [
-            Math.min(currentRange[0], baselineRange[0], targetRange[0]),
-            Math.max(currentRange[1], baselineRange[1], targetRange[1]),
-        ];
</del><ins>+        var seriesList = [this._currentTimeSeries, this._movingAverageTimeSeries, this._baselineTimeSeries, this._targetTimeSeries];
+        var min = Infinity;
+        var max = -Infinity;
+        for (var i = 0; i &lt; seriesList.length; i++) {
+            if (seriesList[i]) {
+                var minMax = seriesList[i].minMaxForTimeRange(startTime, endTime, ignoreOutliners);
+                min = Math.min(min, minMax[0]);
+                max = Math.max(max, minMax[1]);
+            }
+        }
+        return [min, max];
</ins><span class="cx">     },
</span><span class="cx">     _currentSelection: function ()
</span><span class="cx">     {
</span></span></pre>
</div>
</div>

</body>
</html>