[JSC] Allow JSBench to use precise time
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 May 2016 00:40:09 +0000 (00:40 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 May 2016 00:40:09 +0000 (00:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158050

Reviewed by Geoffrey Garen.

PerformanceTests:

* JSBench/amazon-chrome-win/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/amazon-chrome/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/amazon-firefox-win/urm.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/amazon-firefox/urm.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/amazon-safari/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/facebook-chrome-win/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/facebook-chrome/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/facebook-firefox-win/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/facebook-firefox/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/facebook-safari/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/google-chrome-win/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/google-chrome/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/google-firefox-win/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/google-firefox/uem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/google-safari/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/harness.js:
(runBenchmark.window.currentTimeInMS):
(runBenchmark.else.window.currentTimeInMS):
* JSBench/twitter-chrome-win/rem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/twitter-chrome/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/twitter-firefox-win/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/twitter-firefox/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/twitter-safari/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/yahoo-chrome-win/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/yahoo-chrome/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/yahoo-firefox-win/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/yahoo-firefox/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):
* JSBench/yahoo-safari/urem.js:
(else.window.performance.window.performance.now.currentTimeInMS):
(else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
(else.else.currentTimeInMS):
(onload.cb):
(onload):

Tools:

JSBench use `new Date().getTime()` without options and there is no way to use precise time.
This patch modifies the JSBench code to inject the code taking the precise time.
`currentTimeInMS` is given by the benchmerk harness and JSBench uses it.
run-jsc-benchmark switches this function's implementation between `Date.now()` and
testRunner's precise time one.

While this patch modifies the code of JSBench, the last release of JSBench is Jan 2013 and
the contents are not changed for a long time. As described in the original paper[1], the
tests can be generated by using JSBench's record & replay system, but in that case, we can
adopt this modification by changing the tool side.

We also add currentTimeInMS implementation in harness.js and u?rem.js directly.
u?rem.js implementation is required when it is executed in u?rem.html without harness.
And harness.js implementation is required when it is executed in the JSBench's harness.
In these implementation, we follow the JetStream's time measuring function: performance.now(),
preciseTime(), or Date.now().

[1]: http://dl.acm.org/citation.cfm?id=2048119

* Scripts/run-jsc-benchmarks:

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

29 files changed:
PerformanceTests/ChangeLog
PerformanceTests/JSBench/amazon-chrome-win/urem.js
PerformanceTests/JSBench/amazon-chrome/urem.js
PerformanceTests/JSBench/amazon-firefox-win/urm.js
PerformanceTests/JSBench/amazon-firefox/urm.js
PerformanceTests/JSBench/amazon-safari/urem.js
PerformanceTests/JSBench/facebook-chrome-win/urem.js
PerformanceTests/JSBench/facebook-chrome/urem.js
PerformanceTests/JSBench/facebook-firefox-win/urem.js
PerformanceTests/JSBench/facebook-firefox/urem.js
PerformanceTests/JSBench/facebook-safari/urem.js
PerformanceTests/JSBench/google-chrome-win/urem.js
PerformanceTests/JSBench/google-chrome/urem.js
PerformanceTests/JSBench/google-firefox-win/urem.js
PerformanceTests/JSBench/google-firefox/uem.js
PerformanceTests/JSBench/google-safari/urem.js
PerformanceTests/JSBench/harness.js
PerformanceTests/JSBench/twitter-chrome-win/rem.js
PerformanceTests/JSBench/twitter-chrome/urem.js
PerformanceTests/JSBench/twitter-firefox-win/urem.js
PerformanceTests/JSBench/twitter-firefox/urem.js
PerformanceTests/JSBench/twitter-safari/urem.js
PerformanceTests/JSBench/yahoo-chrome-win/urem.js
PerformanceTests/JSBench/yahoo-chrome/urem.js
PerformanceTests/JSBench/yahoo-firefox-win/urem.js
PerformanceTests/JSBench/yahoo-firefox/urem.js
PerformanceTests/JSBench/yahoo-safari/urem.js
Tools/ChangeLog
Tools/Scripts/run-jsc-benchmarks

index 0bd70db6abbecec0eb8907d56c9fe891111ab48a..d25f3a956eae3131ea2970fb85fb289c71bd1e02 100644 (file)
@@ -1,3 +1,164 @@
+2016-05-26  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [JSC] Allow JSBench to use precise time
+        https://bugs.webkit.org/show_bug.cgi?id=158050
+
+        Reviewed by Geoffrey Garen.
+
+        * JSBench/amazon-chrome-win/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/amazon-chrome/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/amazon-firefox-win/urm.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/amazon-firefox/urm.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/amazon-safari/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/facebook-chrome-win/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/facebook-chrome/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/facebook-firefox-win/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/facebook-firefox/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/facebook-safari/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/google-chrome-win/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/google-chrome/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/google-firefox-win/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/google-firefox/uem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/google-safari/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/harness.js:
+        (runBenchmark.window.currentTimeInMS):
+        (runBenchmark.else.window.currentTimeInMS):
+        * JSBench/twitter-chrome-win/rem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/twitter-chrome/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/twitter-firefox-win/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/twitter-firefox/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/twitter-safari/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/yahoo-chrome-win/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/yahoo-chrome/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/yahoo-firefox-win/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/yahoo-firefox/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+        * JSBench/yahoo-safari/urem.js:
+        (else.window.performance.window.performance.now.currentTimeInMS):
+        (else.else.typeof.preciseTime.string_appeared_here.currentTimeInMS):
+        (else.else.currentTimeInMS):
+        (onload.cb):
+        (onload):
+
 2016-05-25  Geoffrey Garen  <ggaren@apple.com>
 
         replaceable own properties seem to ignore replacement after property caching
index 515ce9e0c0336c0f9f9af0aceae448c91e434ed4..a95fd9ca98652d1c12be51f64324f5bf4b9ad130 100644 (file)
@@ -186,6 +186,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -194,7 +206,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -227,7 +239,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index dbc8d316b4f3d80e457e6dd0545dbbfac3b9dabc..7f34fd5fa16de94d1f00b555f31bc6351bfd5e61 100644 (file)
@@ -189,6 +189,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -197,7 +209,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -230,7 +242,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index 67381cf4b76885e6f422ed4da8012934dc14631a..7ae7f9e2eb4d576b8a7be9dabb3ef91bdec48d23 100644 (file)
@@ -186,6 +186,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -194,7 +206,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -227,7 +239,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index 99f234cdbe83c9b33f7c6db15a765336cd4c4117..c9275e412944de68aef76fcca2eb1d2d4db5a7a6 100644 (file)
@@ -189,6 +189,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -197,7 +209,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -230,7 +242,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index af484bb387e186229b6fdfeaec479ee8989db594..93232766ed8ea8e5f3cd7689b647930f83c9b844 100644 (file)
@@ -189,6 +189,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -197,7 +209,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -230,7 +242,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index 09c9d2688a8fa31cec79c3751d43588dd8284120..0416a841a084c61a598e5e070e0d57f9027ff097 100644 (file)
@@ -186,6 +186,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -194,7 +206,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -227,7 +239,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index 06d1f0127486e2dd8011d0a55b437c8f83a8ac93..eead25930c5cd81a19a031b771dd3c2c14ff2f3c 100644 (file)
@@ -186,6 +186,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -194,7 +206,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -227,7 +239,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index 0e1e783e9b0fdab22659a785fa0549f30f3dce5e..734e38817fc76d79bf5e206938f7de57ab4325f4 100644 (file)
@@ -186,6 +186,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -194,7 +206,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -227,7 +239,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index faceb8a2454c317e50a6e36997500348bbd69b1a..d53b52f887dd73a2ce3dda75a9267234470d0d68 100644 (file)
@@ -186,6 +186,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -194,7 +206,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -227,7 +239,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index d54efd9a9570218d84e9216aca069eeff2587cce..178c5636eefa7fd385cc5f8dbf561451f53b9915 100644 (file)
@@ -186,6 +186,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -194,7 +206,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -227,7 +239,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index f35fd7f7ae30c14b4fb38269bdc5f10177f5ba0a..a0161863932c3b5c17a05ff9f99034afa978b76e 100644 (file)
@@ -186,6 +186,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -194,7 +206,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -227,7 +239,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index 99acd951bc136cc8350b794079d14977e82a7348..e6b7ffd4db6b6c831adba4f4bdc9b2034b48c6cc 100644 (file)
@@ -189,6 +189,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -197,7 +209,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -230,7 +242,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index 83b52af92dd5cbbc9afc08c32c0b28ebafee5522..7d66706fbb8b5cefa0326b5cf8359d148811e234 100644 (file)
@@ -186,6 +186,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -194,7 +206,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -227,7 +239,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index 98377f5bbb326b3572521b10c004a288475e1adf..73ebc015e6b6fcb69b755de6a00bedc3e30433e9 100644 (file)
@@ -189,6 +189,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -197,7 +209,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -230,7 +242,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index 3680531e5906cdac2b370d2bc2daf0c2c70d401b..4699fb7604b0706330e2faa60382bab47466ce83 100644 (file)
@@ -189,6 +189,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -197,7 +209,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -230,7 +242,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index 83faa47e75d86b5a1fae61dad02a3068f56bcf09..cac1e580485d26c0a1d72a6dbdbfbc2a0cf60e91 100644 (file)
         if (!(benchmark in results)) results[benchmark] = {};
         if (!(mode in results[benchmark])) results[benchmark][mode] = [];
 
+        // Expose time measuring function.
+        if (window.performance && window.performance.now)
+            window.currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            window.currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            window.currentTimeInMS = function() { return Date.now(); };
+
         // set up the receiver
         if (/v/.test(mode)) {
             // verification mode, we only care if there's an error
index a5215ec10b1b28937bb5d3f61241f7df1f535465..879b142864d2e39cb3184841abe26830c8b6dcf9 100644 (file)
@@ -186,6 +186,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -194,7 +206,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -227,7 +239,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index e20ab4ca78c4c74e71fab27369967db6b06e146b..e3f3643b71680914afa298dee56b11046408f68c 100644 (file)
@@ -189,6 +189,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -197,7 +209,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -230,7 +242,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index cda5c5773a1ca0d8fa04060982310a0d17ce6a48..6a6ffc3f473183e6d6bda4bb616dd10fe68c6cb8 100644 (file)
@@ -186,6 +186,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -194,7 +206,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -227,7 +239,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index f2184a53595ba4e762ea431ca831d0afc831401e..87311bfa9b7ac948f8dca32401a6130ac441a7f3 100644 (file)
@@ -189,6 +189,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -197,7 +209,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -230,7 +242,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index 1841fca7a51330bc87dd16b100e003b6126f857c..70cca9ec14dea7c11c1497e364bb660ecef353b2 100644 (file)
@@ -189,6 +189,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -197,7 +209,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -230,7 +242,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index f565682700415eca57938cd2db3211423b6d49af..0da5c5f4366b0bda55facf90af8d8a3baa90d6ca 100644 (file)
@@ -186,6 +186,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -194,7 +206,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -227,7 +239,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index e77928788febdc3074048f42af51f80c9dda950b..a4dfbb5623eda120ccec0f98705aad34d4c73e07 100644 (file)
@@ -186,6 +186,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -194,7 +206,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -227,7 +239,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index 8ad9dad55cc7c2dfb70c644192e32849f2de6585..53717dc4accc2f6e752ce3b83dbd74ff053f83b3 100644 (file)
@@ -186,6 +186,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -194,7 +206,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -227,7 +239,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index 0b4d47927cb9e9a5816bcfee616acb6cfef5e417..457e66c32e3dd0f73fa9166545dc3b47f769b736 100644 (file)
@@ -186,6 +186,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -194,7 +206,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -227,7 +239,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index cc9128153b7c497fe8e7cc794ae48ee5934a17aa..ee5c78558c8487a1a48c429adc618047b692ebb6 100644 (file)
@@ -186,6 +186,18 @@ if (Object.defineProperty) {
         }
     };
 
+    var currentTimeInMS;
+    if (inharness) {
+        currentTimeInMS = window.parent.currentTimeInMS;
+    } else {
+        if (window.performance && window.performance.now)
+            currentTimeInMS = function() { return window.performance.now() };
+        else if (typeof preciseTime !== 'undefined')
+            currentTimeInMS = function() { return preciseTime() * 1000; };
+        else
+            currentTimeInMS = function() { return Date.now(); };
+    }
+
     // the actual replay runner
     function onload() {
         try {
@@ -194,7 +206,7 @@ if (Object.defineProperty) {
 
         var jr = JSBNG_Replay$;
         var cb = function() {
-            var end = new Date().getTime();
+            var end = currentTimeInMS();
             finished = true;
 
             var msg = "Time: " + (end - st) + "ms";
@@ -227,7 +239,7 @@ if (Object.defineProperty) {
         jr(false);
 
         // then time it
-        var st = new Date().getTime();
+        var st = currentTimeInMS();
         while (jr !== null) {
             jr = jr(true, cb);
         }
index 12006330c45fdd878591613d6494aee7119194e5..2251a39b26728659c936139a26b7efee65be7343 100644 (file)
@@ -1,3 +1,31 @@
+2016-05-26  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [JSC] Allow JSBench to use precise time
+        https://bugs.webkit.org/show_bug.cgi?id=158050
+
+        Reviewed by Geoffrey Garen.
+
+        JSBench use `new Date().getTime()` without options and there is no way to use precise time.
+        This patch modifies the JSBench code to inject the code taking the precise time.
+        `currentTimeInMS` is given by the benchmerk harness and JSBench uses it.
+        run-jsc-benchmark switches this function's implementation between `Date.now()` and
+        testRunner's precise time one.
+
+        While this patch modifies the code of JSBench, the last release of JSBench is Jan 2013 and
+        the contents are not changed for a long time. As described in the original paper[1], the
+        tests can be generated by using JSBench's record & replay system, but in that case, we can
+        adopt this modification by changing the tool side.
+
+        We also add currentTimeInMS implementation in harness.js and u?rem.js directly.
+        u?rem.js implementation is required when it is executed in u?rem.html without harness.
+        And harness.js implementation is required when it is executed in the JSBench's harness.
+        In these implementation, we follow the JetStream's time measuring function: performance.now(),
+        preciseTime(), or Date.now().
+
+        [1]: http://dl.acm.org/citation.cfm?id=2048119
+
+        * Scripts/run-jsc-benchmarks:
+
 2016-05-26  Brent Fulgham  <bfulgham@apple.com>
 
         Unreviewed test fix after r201427.
index 47f130ceac63491fca3e099c066e116cfbd8bde8..6c64a26a4ec504caca4f0a31a4c672dff1df7333 100755 (executable)
@@ -1032,6 +1032,11 @@ def emitBenchRunCodeFile(name, plan, benchParams)
       doublePuts($stderr,file,"function reportResult(result) {")
       doublePuts($stderr,file,"    __bencher_continuation(result);")
       doublePuts($stderr,file,"}")
+      doublePuts($stderr,file,"")
+      doublePuts($stderr,file,"function currentTimeInMS(msg)")
+      doublePuts($stderr,file,"{")
+      doublePuts($stderr,file,"    return #{curTime};")
+      doublePuts($stderr,file,"}")
       if benchParams.kind == :singleFileTimedCallbackBenchmark
         doublePuts($stderr,file,"")
         doublePuts($stderr,file,benchParams.callbackDecl)