[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 0bd70db..d25f3a9 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 515ce9e..a95fd9c 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 dbc8d31..7f34fd5 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 67381cf..7ae7f9e 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 99f234c..c9275e4 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 af484bb..9323276 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 09c9d26..0416a84 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 06d1f01..eead259 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 0e1e783..734e388 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 faceb8a..d53b52f 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 d54efd9..178c563 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 f35fd7f..a016186 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 99acd95..e6b7ffd 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 83b52af..7d66706 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 98377f5..73ebc01 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 3680531..4699fb7 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 83faa47..cac1e58 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 a5215ec..879b142 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 e20ab4c..e3f3643 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 cda5c57..6a6ffc3 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 f2184a5..87311bf 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 1841fca..70cca9e 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 f565682..0da5c5f 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 e779287..a4dfbb5 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 8ad9dad..53717dc 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 0b4d479..457e66c 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 cc91281..ee5c785 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 1200633..2251a39 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 47f130c..6c64a26 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)