Title: [233564] trunk/Websites/perf.webkit.org
Revision
233564
Author
dewei_...@apple.com
Date
2018-07-05 22:57:48 -0700 (Thu, 05 Jul 2018)

Log Message

MeasurementSet should merge last four segments into two if values are identical.
https://bugs.webkit.org/show_bug.cgi?id=187311

Reviewed by Ryosuke Niwa.

If last four segments has the same value, MeasurmentSet should merge them.

* public/v3/models/measurement-set.js: Added the logic to conditionally merge last segments.
(MeasurementSet.prototype.fetchSegmentation):
* unit-tests/measurement-set-tests.js: Added a unit test for this change.

Modified Paths

Diff

Modified: trunk/Websites/perf.webkit.org/ChangeLog (233563 => 233564)


--- trunk/Websites/perf.webkit.org/ChangeLog	2018-07-06 05:50:17 UTC (rev 233563)
+++ trunk/Websites/perf.webkit.org/ChangeLog	2018-07-06 05:57:48 UTC (rev 233564)
@@ -1,3 +1,16 @@
+2018-07-03  Dewei Zhu  <dewei_...@apple.com>
+
+        MeasurementSet should merge last four segments into two if values are identical.
+        https://bugs.webkit.org/show_bug.cgi?id=187311
+
+        Reviewed by Ryosuke Niwa.
+
+        If last four segments has the same value, MeasurmentSet should merge them.
+
+        * public/v3/models/measurement-set.js: Added the logic to conditionally merge last segments.
+        (MeasurementSet.prototype.fetchSegmentation):
+        * unit-tests/measurement-set-tests.js: Added a unit test for this change.
+
 2018-06-29  Dewei Zhu  <dewei_...@apple.com>
 
         Manifest.reset should clear static map for BugTracker and Bug objects.

Modified: trunk/Websites/perf.webkit.org/public/v3/models/measurement-set.js (233563 => 233564)


--- trunk/Websites/perf.webkit.org/public/v3/models/measurement-set.js	2018-07-06 05:50:17 UTC (rev 233563)
+++ trunk/Websites/perf.webkit.org/public/v3/models/measurement-set.js	2018-07-06 05:57:48 UTC (rev 233564)
@@ -224,22 +224,25 @@
         var self = this;
         return Promise.all(promises).then(function (clusterSegmentations) {
             var segmentationSeries = [];
-            var addSegment = function (startingPoint, endingPoint) {
+            var addSegmentMergingIdenticalSegments = function (startingPoint, endingPoint) {
                 var value = Statistics.mean(timeSeries.valuesBetweenRange(startingPoint.seriesIndex, endingPoint.seriesIndex));
-                segmentationSeries.push({value: value, time: startingPoint.time, seriesIndex: startingPoint.seriesIndex, interval: function () { return null; }});
-                segmentationSeries.push({value: value, time: endingPoint.time, seriesIndex: endingPoint.seriesIndex, interval: function () { return null; }});
+                if (!segmentationSeries.length || value !== segmentationSeries[segmentationSeries.length - 1].value) {
+                    segmentationSeries.push({value: value, time: startingPoint.time, seriesIndex: startingPoint.seriesIndex, interval: function () { return null; }});
+                    segmentationSeries.push({value: value, time: endingPoint.time, seriesIndex: endingPoint.seriesIndex, interval: function () { return null; }});
+                } else
+                    segmentationSeries[segmentationSeries.length - 1].seriesIndex = endingPoint.seriesIndex;
             };
 
-            var startingIndex = 0;
-            for (var segmentation of clusterSegmentations) {
-                for (var endingIndex of segmentation) {
-                    addSegment(timeSeries.findPointByIndex(startingIndex), timeSeries.findPointByIndex(endingIndex));
+            let startingIndex = 0;
+            for (const segmentation of clusterSegmentations) {
+                for (const endingIndex of segmentation) {
+                    addSegmentMergingIdenticalSegments(timeSeries.findPointByIndex(startingIndex), timeSeries.findPointByIndex(endingIndex));
                     startingIndex = endingIndex;
                 }
             }
             if (extendToFuture)
                 timeSeries.extendToFuture();
-            addSegment(timeSeries.findPointByIndex(startingIndex), timeSeries.lastPoint());
+            addSegmentMergingIdenticalSegments(timeSeries.findPointByIndex(startingIndex), timeSeries.lastPoint());
             return segmentationSeries;
         });
     }

Modified: trunk/Websites/perf.webkit.org/unit-tests/measurement-set-tests.js (233563 => 233564)


--- trunk/Websites/perf.webkit.org/unit-tests/measurement-set-tests.js	2018-07-06 05:50:17 UTC (rev 233563)
+++ trunk/Websites/perf.webkit.org/unit-tests/measurement-set-tests.js	2018-07-06 05:57:48 UTC (rev 233564)
@@ -956,6 +956,38 @@
             1587.1390, 1594.5451, 1586.2430, 1596.7310, 1548.1423
         ];
 
+        const segmentableValuesWithSameValueInTheEnd = [
+            58.682259702925, 58.672894300682, 58.631641849076, 58.627144214832, 58.600152967236, 58.494227167544, 58.599711218167,
+            58.547823321802, 58.698848676888, 58.508972506625, 58.469396077128, 58.556437051089, 58.604914035672, 58.571468615261,
+            58.594861298965, 58.579862593826, 58.737724228989, 58.559390128467, 58.662054613527, 58.487359249788, 58.668808926954,
+            58.553303046256, 58.569416814443, 58.626218640839, 58.558458933333, 58.750789167464, 58.510114013725, 58.69285535498,
+            58.485630989257, 58.578345118044, 58.582484886505, 58.532783559929, 58.609545975048, 58.577426480631, 58.646940753247,
+            58.682440825246, 58.690139834194, 58.553030894519, 58.48355532648, 58.562671977345, 58.736913200555, 58.601320380111,
+            58.505524628951, 58.719286182364, 58.58550401243, 58.610740664944, 58.666584852042, 58.65066016161, 58.482425957387,
+            58.661528735444, 58.518979531621, 58.541899532138, 58.682011833211, 58.728042515799, 58.585571499659, 58.514042621815,
+            58.577703157219, 58.599122230584, 58.484605706445, 58.627013987028, 58.732535874422, 58.647810220687, 58.484710879088,
+            58.60018559995, 58.474169516583, 58.556748299505, 58.591036051726, 58.71549080058, 58.665731757591, 58.632681499924,
+            58.552549642854, 58.584740710795, 58.636732559301, 58.53269727482, 58.685214845539, 58.537642664213, 58.539530819775,
+            58.593108102721, 58.677797677387, 58.634261295951, 58.585087893228, 58.595892348834, 58.530958396798, 58.642329444242,
+            58.523362771471, 58.472298233318, 58.608844095124, 58.637822365233, 58.532578586691, 58.561802676135, 58.525325974291,
+            58.546952858346, 58.628146092218, 58.676781325555, 58.537737927017, 58.517186448238, 58.517186448238, 58.48698590938,
+            58.573592928243, 58.51865286684, 58.479829555547, 58.458334022968, 58.523846961495, 58.549153451184, 58.634999646062,
+            58.651469426158, 58.604400895147, 58.520828892369, 58.461372117238, 58.458419659482, 58.558429870762, 58.520353913269,
+            58.505030130601, 58.558693442114, 58.583541042224, 58.635994108477, 58.596789439588, 58.523974765221, 58.578794417346,
+            58.468486231053, 58.498525892758, 58.735390962226, 58.648008111097, 58.466341359719, 58.461193386858, 58.669176655316,
+            58.517108713145, 58.580728461245, 58.566096647056, 58.56041778812, 58.541417728709, 58.508221589085, 58.411457477143,
+            58.451664940683, 58.583113913556, 58.612464741978, 58.620718400402, 58.632099100152, 58.566486756057, 58.624483547469,
+            58.55432867294, 58.563472285719, 58.600277699686, 58.489114861265, 58.614875239224, 58.519637811989, 58.538987481917,
+            58.538522915164, 58.524365991229, 58.527404019557, 58.545873059444, 58.546814673224, 58.5387615282, 58.600516560328,
+            58.599054345431, 58.593909039083, 58.640076570937, 58.522330600933, 58.593842010201, 58.476540680164, 58.436866978957,
+            58.642057826523, 58.639790605443, 58.601606301724, 58.639790605443, 58.632119472725, 58.525704127801, 58.589769044991,
+            58.655170757252, 58.639790605443, 58.665187550878, 58.728890733238, 58.639790605443, 58.522175015522, 58.569765368371,
+            58.504822400604, 58.569230880769, 58.590753393869, 58.628160118689, 58.522175015522, 58.666019881578, 58.522175015522,
+            58.522175015522, 58.522175015522, 58.639790605443, 58.639790605443, 58.425335418429, 58.425335418429, 58.425335418429,
+            58.425335418429, 58.425335418429, 58.425335418429, 58.520895333629, 58.520895333629, 58.520895333629, 58.520895333629,
+            58.520895333629
+        ];
+
         function makeSampleRuns(values, startRunId, startTime, timeIncrement)
         {
             var runId = startRunId;
@@ -1011,6 +1043,37 @@
             });
         });
 
+        it('should merge last four segments into two if values are identical', async () => {
+            const set = MeasurementSet.findSet(1, 1, 5000);
+            set.fetchBetween(4000, 5000);
+            assert.equal(requests.length, 1);
+            assert.equal(requests[0].url, '/data/measurement-set-1-1.json');
+
+            requests[0].resolve({
+                'clusterStart': 1000,
+                'clusterSize': 1000,
+                'formatMap': ['id', 'mean', 'iterationCount', 'sum', 'squareSum', 'markedOutlier', 'revisions', 'commitTime', 'build', 'buildTime', 'buildNumber', 'builder'],
+                'configurations': {current: makeSampleRuns(segmentableValuesWithSameValueInTheEnd, 6400, 4000, 1000 / 200)},
+                'startTime': 4000,
+                'endTime': 5000,
+                'lastModified': 5000,
+                'clusterCount': 4,
+                'status': 'OK'});
+
+            var timeSeries;
+            assert.equal(set.fetchedTimeSeries('current', false, false).length(), 0);
+
+            await waitForMeasurementSet();
+
+            timeSeries = set.fetchedTimeSeries('current', false, false);
+            assert.equal(timeSeries.length(), 197);
+            assert.equal(timeSeries.firstPoint().time, 4000);
+            assert.equal(timeSeries.lastPoint().time, 4980);
+
+            const segmentation = await set.fetchSegmentation('segmentTimeSeriesByMaximizingSchwarzCriterion', [], 'current', false);
+            assert.equal(segmentation.length, 8);
+        });
+
         it('should be able to segment two clusters', () => {
             const set = MeasurementSet.findSet(1, 1, 5000);
             const promise = set.fetchBetween(3000, 5000);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to