Add option to use different methods for retrieving a timestamp.
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Feb 2016 03:30:26 +0000 (03:30 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Feb 2016 03:30:26 +0000 (03:30 +0000)
* Animometer/developer.html: Add performance.now and Date.now options.
* Animometer/resources/runner/animometer.js: Default to performance.now.
(window.benchmarkController.startBenchmark):
* Animometer/tests/resources/main.js: Tie the desired method to _getTimestamp.
(run): Use _getTimestamp.
(_animateLoop): Ditto.

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

PerformanceTests/Animometer/developer.html
PerformanceTests/Animometer/resources/runner/animometer.js
PerformanceTests/Animometer/tests/resources/main.js
PerformanceTests/ChangeLog

index c58428b..51f2bac 100644 (file)
                             <li><label>Measurement error (R): <input type="number" id="kalman-measurement-error" value="4"></label></li>
                         </ul>
                     </li>
+                    <li>
+                        <h3>Time measurement method:</h3>
+                        <ul>
+                            <li><label><input name="time-measurement" type="radio" value="performance" checked> <code>performance.now()</code></label></li>
+                            <li><label><input name="time-measurement" type="radio" value="date"> <code>Date.now()</code></label></li>
+                        </ul>
+                    </li>
                     </ul>
                     </form>
                 </div>
index 1b49a50..74c596b 100644 (file)
@@ -308,7 +308,8 @@ window.benchmarkController = {
             "adjustment": "adaptive",
             "frame-rate": 50,
             "kalman-process-error": 1,
-            "kalman-measurement-error": 4
+            "kalman-measurement-error": 4,
+            "time-measurement": "performance"
         };
         this._startBenchmark(Suites, options, "test-container");
     },
index 7cf5942..96166a4 100644 (file)
@@ -329,6 +329,16 @@ Benchmark = Utilities.createClass(
         this._stage = stage;
         this._stage.initialize(this, options);
 
+        switch (options["time-measurement"])
+        {
+        case "performance":
+            this._getTimestamp = performance.now.bind(performance);
+            break;
+        case "date":
+            this._getTimestamp = Date.now;
+            break;
+        }
+
         var testIntervalMilliseconds = options["test-interval"] * 1000;
         switch (options["adjustment"])
         {
@@ -351,7 +361,7 @@ Benchmark = Utilities.createClass(
     {
         return this.waitUntilReady().then(function() {
             this._finishPromise = new SimplePromise;
-            this._previousTimestamp = performance.now();
+            this._previousTimestamp = this._getTimestamp();
             this._didWarmUp = false;
             this._stage.tune(this._controller.initialComplexity - this._stage.complexity());
             this._animateLoop();
@@ -369,7 +379,7 @@ Benchmark = Utilities.createClass(
 
     _animateLoop: function()
     {
-        this._currentTimestamp = performance.now();
+        this._currentTimestamp = this._getTimestamp();
 
         if (!this._didWarmUp) {
             if (this._currentTimestamp - this._previousTimestamp >= 100) {
index aea3447..2f05023 100644 (file)
@@ -1,5 +1,16 @@
 2016-02-07  Jon Lee  <jonlee@apple.com>
 
+        Add option to use different methods for retrieving a timestamp.
+
+        * Animometer/developer.html: Add performance.now and Date.now options.
+        * Animometer/resources/runner/animometer.js: Default to performance.now.
+        (window.benchmarkController.startBenchmark):
+        * Animometer/tests/resources/main.js: Tie the desired method to _getTimestamp.
+        (run): Use _getTimestamp.
+        (_animateLoop): Ditto.
+
+2016-02-07  Jon Lee  <jonlee@apple.com>
+
         Allow adding any number of markers to the graph. The markers can be labeled
         and contain timestamp and sample index data. Make it a part of the controller
         rather than keeping it in the sampler.