Teach Controller to measure intervals, and turn off the frame length estimator.
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Feb 2016 03:30:52 +0000 (03:30 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Feb 2016 03:30:52 +0000 (03:30 +0000)
* Animometer/tests/resources/main.js: Default interval length is 100 ms.
(start): Set the first interval.
(_measureAndResetInterval): Reports the average frame length of the interval that just
completed, and sets up the next interval.
(update): If there is no length, then just use the estimator per frame, otherwise the
estimator measures per interval. Add a didFinishInterval for subclasses to process
prior to recording the sample. Update tune() to include whether an interval had
finished.
(StepController): Step controllers don't measure on an interval basis.

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

PerformanceTests/Animometer/tests/resources/main.js
PerformanceTests/ChangeLog

index cbf3e27..1a306f5 100644 (file)
@@ -10,14 +10,23 @@ Controller = Utilities.createClass(
         this._marks = {};
 
         this._frameLengthEstimator = new SimpleKalmanEstimator(options["kalman-process-error"], options["kalman-measurement-error"]);
+        this._isFrameLengthEstimatorEnabled = true;
+
+        // Length of subsequent intervals; a value of 0 means use no intervals
+        this._intervalLength = options["interval-length"] || 100;
 
         this.initialComplexity = 0;
     }, {
 
+    set isFrameLengthEstimatorEnabled(enabled) {
+        this._isFrameLengthEstimatorEnabled = enabled;
+    },
+
     start: function(startTimestamp, stage)
     {
         this._startTimestamp = startTimestamp;
         this._endTimestamp += startTimestamp;
+        this._measureAndResetInterval(startTimestamp);
         this.recordFirstSample(startTimestamp, stage);
     },
 
@@ -38,15 +47,51 @@ Controller = Utilities.createClass(
         return comment in this._marks;
     },
 
+    _measureAndResetInterval: function(currentTimestamp)
+    {
+        var sampleCount = this._sampler.sampleCount;
+        var averageFrameLength = 0;
+
+        if (this._intervalEndTimestamp) {
+            var intervalStartTimestamp = this._sampler.samples[0][this._intervalStartIndex];
+            averageFrameLength = (currentTimestamp - intervalStartTimestamp) / (sampleCount - this._intervalStartIndex);
+        }
+
+        this._intervalStartIndex = sampleCount;
+        this._intervalEndTimestamp = currentTimestamp + this._intervalLength;
+
+        return averageFrameLength;
+    },
+
     update: function(timestamp, stage)
     {
-        this._frameLengthEstimator.sample(timestamp - this._sampler.samples[0][this._sampler.sampleCount - 1]);
-        this._sampler.record(timestamp, stage.complexity(), this._frameLengthEstimator.estimate);
+        var frameLengthEstimate = -1;
+        var didFinishInterval = false;
+        if (!this._intervalLength) {
+            if (this._isFrameLengthEstimatorEnabled) {
+                this._frameLengthEstimator.sample(timestamp - this._sampler.samples[0][this._sampler.sampleCount - 1]);
+                frameLengthEstimate = this._frameLengthEstimator.estimate;
+            }
+        } else if (timestamp >= this._intervalEndTimestamp) {
+            var intervalStartTimestamp = this._sampler.samples[0][this._intervalStartIndex];
+            intervalAverageFrameLength = this._measureAndResetInterval(timestamp);
+            if (this._isFrameLengthEstimatorEnabled) {
+                this._frameLengthEstimator.sample(intervalAverageFrameLength);
+                frameLengthEstimate = this._frameLengthEstimator.estimate;
+            }
+            didFinishInterval = true;
+            this.didFinishInterval(timestamp, stage, intervalAverageFrameLength);
+        }
 
-        this.tune(timestamp, stage);
+        this._sampler.record(timestamp, stage.complexity(), frameLengthEstimate);
+        this.tune(timestamp, stage, didFinishInterval);
     },
 
-    tune: function(timestamp, stage)
+    didFinishInterval: function(timestamp, stage, intervalAverageFrameLength)
+    {
+    },
+
+    tune: function(timestamp, stage, didFinishInterval)
     {
     },
 
@@ -123,6 +168,7 @@ Controller = Utilities.createClass(
 StepController = Utilities.createSubclass(Controller,
     function(benchmark, options)
     {
+        options["interval-length"] = 0;
         Controller.call(this, benchmark, options);
         this.initialComplexity = options["complexity"];
         this._stepped = false;
index 18c106f..6d49f07 100644 (file)
@@ -1,5 +1,19 @@
 2016-02-07  Jon Lee  <jonlee@apple.com>
 
+        Teach Controller to measure intervals, and turn off the frame length estimator.
+
+        * Animometer/tests/resources/main.js: Default interval length is 100 ms.
+        (start): Set the first interval.
+        (_measureAndResetInterval): Reports the average frame length of the interval that just
+        completed, and sets up the next interval.
+        (update): If there is no length, then just use the estimator per frame, otherwise the
+        estimator measures per interval. Add a didFinishInterval for subclasses to process
+        prior to recording the sample. Update tune() to include whether an interval had
+        finished.
+        (StepController): Step controllers don't measure on an interval basis.
+
+2016-02-07  Jon Lee  <jonlee@apple.com>
+
         Minor refactoring. Rename Controller._estimator to Controller._frameLengthEstimator
         and switch the parameters for start(), update(), and tune(), so that the timestamp
         is first and stage is second.