Automate JSBench with run-benchmark
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Aug 2015 22:23:31 +0000 (22:23 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Aug 2015 22:23:31 +0000 (22:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147716

Reviewed by Chris Dumez.

Added JSBench plan to run-benchmark.

* Scripts/webkitpy/benchmark_runner/benchmark_builder/generic_benchmark_builder.py:
(GenericBenchmarkBuilder.prepare): Pass in the archive type to _fetch_remote_archive.
(GenericBenchmarkBuilder._fetch_remote_archive): Added the support for extracting files from tar.gz in addition to zip.
* Scripts/webkitpy/benchmark_runner/data/patches/Dromaeo.patch: Fixed the coding style.
* Scripts/webkitpy/benchmark_runner/data/patches/JSBench.patch: Added.
* Scripts/webkitpy/benchmark_runner/data/patches/JetStream.patch: Fixed the coding style.
* Scripts/webkitpy/benchmark_runner/data/patches/Kraken.patch: Ditto.
* Scripts/webkitpy/benchmark_runner/data/patches/Octane.patch: Ditto.
* Scripts/webkitpy/benchmark_runner/data/patches/SunSpider.patch: Ditto.
* Scripts/webkitpy/benchmark_runner/data/plans/dromaeo-cssquery.plan: Specified the archive type.
* Scripts/webkitpy/benchmark_runner/data/plans/dromaeo-dom.plan: Specified the archive type.
* Scripts/webkitpy/benchmark_runner/data/plans/dromaeo-jslib.plan: Ditto.
* Scripts/webkitpy/benchmark_runner/data/plans/jetstream.plan: Fixed the coding style.
* Scripts/webkitpy/benchmark_runner/data/plans/jsbench.plan: Added.
* Scripts/webkitpy/benchmark_runner/data/plans/kraken.plan: Specified the archive type.
* Scripts/webkitpy/benchmark_runner/data/plans/octane.plan: Ditto.

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

Tools/ChangeLog
Tools/Scripts/webkitpy/benchmark_runner/benchmark_builder/generic_benchmark_builder.py
Tools/Scripts/webkitpy/benchmark_runner/data/patches/Dromaeo.patch
Tools/Scripts/webkitpy/benchmark_runner/data/patches/JSBench.patch [new file with mode: 0644]
Tools/Scripts/webkitpy/benchmark_runner/data/patches/JetStream.patch
Tools/Scripts/webkitpy/benchmark_runner/data/patches/Kraken.patch
Tools/Scripts/webkitpy/benchmark_runner/data/patches/Octane.patch
Tools/Scripts/webkitpy/benchmark_runner/data/patches/SunSpider.patch
Tools/Scripts/webkitpy/benchmark_runner/data/plans/jetstream.plan
Tools/Scripts/webkitpy/benchmark_runner/data/plans/jsbench.plan [new file with mode: 0644]

index 77f5e5c2a7d45e89e146f0f49401f9294d4aff1d..e49033ade28d0903e9456d8513606531c4175fd6 100644 (file)
@@ -1,3 +1,29 @@
+2015-08-06  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Automate JSBench with run-benchmark
+        https://bugs.webkit.org/show_bug.cgi?id=147716
+
+        Reviewed by Chris Dumez.
+
+        Added JSBench plan to run-benchmark.
+
+        * Scripts/webkitpy/benchmark_runner/benchmark_builder/generic_benchmark_builder.py:
+        (GenericBenchmarkBuilder.prepare): Pass in the archive type to _fetch_remote_archive.
+        (GenericBenchmarkBuilder._fetch_remote_archive): Added the support for extracting files from tar.gz in addition to zip.
+        * Scripts/webkitpy/benchmark_runner/data/patches/Dromaeo.patch: Fixed the coding style.
+        * Scripts/webkitpy/benchmark_runner/data/patches/JSBench.patch: Added.
+        * Scripts/webkitpy/benchmark_runner/data/patches/JetStream.patch: Fixed the coding style.
+        * Scripts/webkitpy/benchmark_runner/data/patches/Kraken.patch: Ditto.
+        * Scripts/webkitpy/benchmark_runner/data/patches/Octane.patch: Ditto.
+        * Scripts/webkitpy/benchmark_runner/data/patches/SunSpider.patch: Ditto.
+        * Scripts/webkitpy/benchmark_runner/data/plans/dromaeo-cssquery.plan: Specified the archive type.
+        * Scripts/webkitpy/benchmark_runner/data/plans/dromaeo-dom.plan: Specified the archive type.
+        * Scripts/webkitpy/benchmark_runner/data/plans/dromaeo-jslib.plan: Ditto.
+        * Scripts/webkitpy/benchmark_runner/data/plans/jetstream.plan: Fixed the coding style.
+        * Scripts/webkitpy/benchmark_runner/data/plans/jsbench.plan: Added.
+        * Scripts/webkitpy/benchmark_runner/data/plans/kraken.plan: Specified the archive type.
+        * Scripts/webkitpy/benchmark_runner/data/plans/octane.plan: Ditto.
+
 2015-08-06  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Pass-through the undefined options in run-jsc
index 272ada408e9696ee4774ace0bf9c7c5e01febe38..eab9807b96c6a06b1a5e0f74f374d0b811d784f2 100644 (file)
@@ -6,6 +6,7 @@ import os
 import urllib
 import shutil
 import subprocess
+import tarfile
 
 from zipfile import ZipFile
 from webkitpy.benchmark_runner.utils import get_path_from_project_root, force_remove
@@ -55,12 +56,23 @@ class GenericBenchmarkBuilder(object):
         shutil.copytree(get_path_from_project_root(benchmark_path), self._dest)
 
     def _fetch_remote_archive(self, archive_url):
-        archive_path = os.path.join(self._web_root, 'archive.zip')
+        if archive_url.endswith('.zip'):
+            archive_type = 'zip'
+        elif archive_url.endswith('tar.gz'):
+            archive_type = 'tar.gz'
+        else:
+            raise Exception('Could not infer the file extention from URL: %s' % archive_url)
+
+        archive_path = os.path.join(self._web_root, 'archive.' + archive_type)
         _log.info('Downloading %s to %s' % (archive_url, archive_path))
         urllib.urlretrieve(archive_url, archive_path)
 
-        with ZipFile(archive_path, 'r') as archive:
-            archive.extractall(self._dest)
+        if archive_type == 'zip':
+            with ZipFile(archive_path, 'r') as archive:
+                archive.extractall(self._dest)
+        elif archive_type == 'tar.gz':
+            with tarfile.open(archive_path, 'r:gz') as archive:
+                archive.extractall(self._dest)
 
         unarchived_files = filter(lambda name: not name.startswith('.'), os.listdir(self._dest))
         if len(unarchived_files) == 1:
index 6f0de85d7a2d8bf0b7af55445dd90e39450c9f96..be7ef774e961348a92a4ffbde8e6672a1e3eaa20 100644 (file)
@@ -40,7 +40,7 @@ index 63d777b..953c026 100755
 +                      xhr.setRequestHeader("Content-Length", results.length);
 +                      xhr.setRequestHeader("Connection", "close");
 +                      xhr.onreadystatechange = function() {
-+                      if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
++                      if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
 +                                      closeRequest = new XMLHttpRequest();
 +                                      closeRequest.open("GET", "/shutdown");
 +                                      closeRequest.send();
diff --git a/Tools/Scripts/webkitpy/benchmark_runner/data/patches/JSBench.patch b/Tools/Scripts/webkitpy/benchmark_runner/data/patches/JSBench.patch
new file mode 100644 (file)
index 0000000..23a4e82
--- /dev/null
@@ -0,0 +1,55 @@
+diff --git a/harness.js b/harness.js
+index 4b9d269..f3f1285 100644
+--- a/harness.js
++++ b/harness.js
+@@ -104,6 +104,7 @@
+                 return;
+             }
+         } catch (ex) {}
++        setTimeout(runBenchmark, 200);
+         gob.onclick = function() {
+             gob.style.display = "none";
+             setTimeout(runBenchmark, 200);
+@@ -207,6 +208,8 @@
+         var spc = "\u00a0\u00a0";
+         var spc2 = spc + spc;
++        var tests = {};
++
+         // calculate all the real results
+         for (var b = 0; b < benchmarks.length; b++) {
+             var benchmark = benchmarks[b];
+@@ -221,6 +224,9 @@
+                 var bmresults = results[benchmark][mode].slice(-keepRuns);
+                 if (bmresults.length == 0) continue;
++                if (pr)
++                    tests[benchmark] = {'metrics': {'Time': {'current': bmresults}}};
++
+                 // get the raw results
+                 var rr = spc2 + mode + ": [";
+                 for (var i = 0; i < bmresults.length; i++) {
+@@ -272,6 +278,23 @@
+             ptotals.push(spc + curRun + " runs");
+         ptotals.push("");
++        if (pr) {
++            var jsonResults = JSON.stringify({"JSBench": {"metrics": {"Time": ["Geometric"]}, "tests": tests}});
++            var xhr = new XMLHttpRequest();
++            xhr.open("POST", "/report");
++            xhr.setRequestHeader("Content-Type", "application/json");
++            xhr.setRequestHeader("Content-Length", jsonResults.length);
++            xhr.setRequestHeader("Connection", "close");
++            xhr.onreadystatechange = function() {
++            if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
++                    closeRequest = new XMLHttpRequest();
++                    closeRequest.open("GET", "/shutdown");
++                    closeRequest.send();
++                }
++            }
++            xhr.send(jsonResults);
++        }
++
+         // if there are errors, mark those too
+         if ("errors" in results) {
+             ptotals.push("ERRORS:");
index 200384e13d6c7ad728cc7f0fd28cbd6fd5712917..da9f32825553334f3f63a58f32cc6e9df8f0b31a 100644 (file)
@@ -31,7 +31,7 @@ index 73ee420..60f587c 100644
 +        xhr.setRequestHeader("Connection", "close");
 + 
 +        xhr.onreadystatechange = function() {
-+        if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
++        if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
 +                closeRequest = new XMLHttpRequest();
 +                closeRequest.open("GET", "/shutdown");
 +                closeRequest.send()
index 9a189a4d24882c9f764af51c80974592c80f63c4..6348b059c15a7fdfc6e41fa22d42dffee3578395 100644 (file)
@@ -32,7 +32,7 @@ index bfb2c94..5ad1704 100644
 +    xhr.setRequestHeader("Content-Length", results.length);
 +    xhr.setRequestHeader("Connection", "close");
 +    xhr.onreadystatechange = function() {
-+    if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
++    if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
 +            closeRequest = new XMLHttpRequest();
 +            closeRequest.open("GET", "/shutdown");
 +            closeRequest.send();
index 2e05e366916bde7a49175b6753537d4a66ec40ef..c3086286b4678eccd0338f16f4312b606170e532 100644 (file)
@@ -56,7 +56,7 @@ index 77cbdfb..fe56fc4
 +    xhr.setRequestHeader("Content-Length", results.length);
 +    xhr.setRequestHeader("Connection", "close");
 +    xhr.onreadystatechange = function() {
-+    if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
++    if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
 +            closeRequest = new XMLHttpRequest();
 +            closeRequest.open("GET", "/shutdown");
 +            closeRequest.send();
index c7f7c0015deedf2a049da0024ce213eb2c29ac7d..43de073d6f99ea49132e524a484e61dbfbd46ced 100644 (file)
@@ -35,7 +35,7 @@ index 0700bb2..2dde01a 100644
 +    xhr.setRequestHeader("Content-Length", results.length);
 +    xhr.setRequestHeader("Connection", "close");
 +    xhr.onreadystatechange = function() {
-+    if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
++    if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
 +            closeRequest = new XMLHttpRequest();
 +            closeRequest.open("GET", "/shutdown");
 +            closeRequest.send();
index 4b2f0ba38d1528220a33b0a94ca17f95f5bab829..941f75598728ee9f73fd0a6f83b8cfa57ae0518c 100644 (file)
@@ -1,6 +1,6 @@
 {
     "http_server_driver": "SimpleHTTPServerDriver", 
-    "timeout" : 600,
+    "timeout": 600,
     "count": 5,
     "benchmark_builder": "GenericBenchmarkBuilder",
     "svn_source": "https://svn.webkit.org/repository/webkit/trunk/PerformanceTests/JetStream/@r183091",
diff --git a/Tools/Scripts/webkitpy/benchmark_runner/data/plans/jsbench.plan b/Tools/Scripts/webkitpy/benchmark_runner/data/plans/jsbench.plan
new file mode 100644 (file)
index 0000000..7749241
--- /dev/null
@@ -0,0 +1,10 @@
+{
+    "http_server_driver": "SimpleHTTPServerDriver", 
+    "timeout": 600,
+    "count": 1,
+    "benchmark_builder": "GenericBenchmarkBuilder",
+    "remote_archive": "http://plg.uwaterloo.ca/~dynjs/jsbench/suite/jsbench-2013.1.tar.gz",
+    "benchmark_patch": "data/patches/JSBench.patch",
+    "entry_point": "index.html",
+    "output_file": "jsbench.result"
+}