The sampling of time series on v3 UI is too aggressive
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Jan 2016 21:16:54 +0000 (21:16 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Jan 2016 21:16:54 +0000 (21:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152804

Reviewed by Chris Dumez.

Fixed a bug that we were always halving the number of data points in _sampleTimeSeries
and increased the number of data points allowed to make the sampling less aggressive.

* public/v3/components/time-series-chart.js:
(TimeSeriesChart.prototype._ensureSampledTimeSeries): Increase the number of maximum points
to 2x the number of pixels divided by the radius of each point.
(TimeSeriesChart.prototype._sampleTimeSeries.findMedian): Changed the semantics of endIndex
to mean the index after the last point and renamed it to indexAfterEnd.
(TimeSeriesChart.prototype._sampleTimeSeries): Fixed a bug that this code always coerced two
data points into one sampled data point despite of the fact i and j are sufficiently apart
since data[j].time - data[i].time > timePerSample by definition.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@194661 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/public/v3/components/time-series-chart.js

index 4629759..4b129ee 100644 (file)
@@ -1,5 +1,24 @@
 2016-01-06  Ryosuke Niwa  <rniwa@webkit.org>
 
+        The sampling of time series on v3 UI is too aggressive
+        https://bugs.webkit.org/show_bug.cgi?id=152804
+
+        Reviewed by Chris Dumez.
+
+        Fixed a bug that we were always halving the number of data points in _sampleTimeSeries
+        and increased the number of data points allowed to make the sampling less aggressive.
+
+        * public/v3/components/time-series-chart.js:
+        (TimeSeriesChart.prototype._ensureSampledTimeSeries): Increase the number of maximum points
+        to 2x the number of pixels divided by the radius of each point.
+        (TimeSeriesChart.prototype._sampleTimeSeries.findMedian): Changed the semantics of endIndex
+        to mean the index after the last point and renamed it to indexAfterEnd.
+        (TimeSeriesChart.prototype._sampleTimeSeries): Fixed a bug that this code always coerced two
+        data points into one sampled data point despite of the fact i and j are sufficiently apart
+        since data[j].time - data[i].time > timePerSample by definition.
+
+2016-01-06  Ryosuke Niwa  <rniwa@webkit.org>
+
         Commit the forgotten change for r194651.
 
         * public/v3/pages/domain-control-toolbar.js:
index 88a944f..9cd4d9e 100644 (file)
@@ -437,8 +437,8 @@ class TimeSeriesChart extends ComponentBase {
             if (!timeSeries)
                 return null;
 
-            // A chart with X px width shouldn't have more than X / <radius-of-points> data points.
-            var maximumNumberOfPoints = metrics.chartWidth / source.pointRadius;
+            // A chart with X px width shouldn't have more than 2X / <radius-of-points> data points.
+            var maximumNumberOfPoints = 2 * metrics.chartWidth / source.pointRadius;
 
             var pointAfterStart = timeSeries.findPointAfterTime(startTime);
             var pointBeforeStart = (pointAfterStart ? timeSeries.previousPoint(pointAfterStart) : null) || timeSeries.firstPoint();
@@ -448,7 +448,7 @@ class TimeSeriesChart extends ComponentBase {
 
             // FIXME: Move this to TimeSeries.prototype.
             var filteredData = timeSeries.dataBetweenPoints(pointBeforeStart, pointAfterEnd);
-            if (filteredData.length <= maximumNumberOfPoints || !source.sampleData)
+            if (!source.sampleData)
                 return filteredData;
             else
                 return self._sampleTimeSeries(filteredData, maximumNumberOfPoints);
@@ -467,9 +467,9 @@ class TimeSeriesChart extends ComponentBase {
         Instrumentation.startMeasuringTime('TimeSeriesChart', 'sampleTimeSeries');
 
         // FIXME: Do this in O(n) using quickselect: https://en.wikipedia.org/wiki/Quickselect
-        function findMedian(list, startIndex, endIndex)
+        function findMedian(list, startIndex, indexAfterEnd)
         {
-            var sortedList = list.slice(startIndex, endIndex + 1).sort(function (a, b) { return a.value - b.value; });
+            var sortedList = list.slice(startIndex, indexAfterEnd).sort(function (a, b) { return a.value - b.value; });
             return sortedList[Math.floor(sortedList.length / 2)];
         }
 
@@ -493,9 +493,9 @@ class TimeSeriesChart extends ComponentBase {
                 if (endPoint.time - startPoint.time >= timePerSample)
                     break;
             }
-            if (i < j) {
+            if (i < j - 1) {
                 sampledData.push(findMedian(data, i, j));
-                i = j + 1;
+                i = j;
             } else {
                 sampledData.push(startPoint);
                 i++;