haikuwebkit/PerformanceTests/JSBench/browsercheck.js

119 lines
4.2 KiB
JavaScript
Raw Permalink Normal View History

We should have JSBench in PerformanceTests https://bugs.webkit.org/show_bug.cgi?id=157952 Rubber-stamped by Saam Barati. PerformanceTests: There are some slight changes to the layout of the test directory to make it work nicely with run-jsc-benchmarks. Before JSBench had each of the browser specific sub-tests in a sub-directory. These have been flattened e.g. amazon/safari/ has become amazon-safari/. * JSBench/amazon-chrome-win/urem.html: Added. * JSBench/amazon-chrome-win/urem.js: Added. * JSBench/amazon-chrome/urem.html: Added. * JSBench/amazon-chrome/urem.js: Added. * JSBench/amazon-firefox-win/urm.html: Added. * JSBench/amazon-firefox-win/urm.js: Added. * JSBench/amazon-firefox/urm.html: Added. * JSBench/amazon-firefox/urm.js: Added. * JSBench/amazon-safari/urem.html: Added. * JSBench/amazon-safari/urem.js: Added. * JSBench/browsercheck.js: Added. * JSBench/facebook-chrome-win/urem.html: Added. * JSBench/facebook-chrome-win/urem.js: Added. * JSBench/facebook-chrome/urem.html: Added. * JSBench/facebook-chrome/urem.js: Added. * JSBench/facebook-firefox-win/urem.html: Added. * JSBench/facebook-firefox-win/urem.js: Added. * JSBench/facebook-firefox/urem.html: Added. * JSBench/facebook-firefox/urem.js: Added. * JSBench/facebook-safari/urem.html: Added. * JSBench/facebook-safari/urem.js: Added. * JSBench/google-chrome-win/urem.html: Added. * JSBench/google-chrome-win/urem.js: Added. * JSBench/google-chrome/urem.html: Added. * JSBench/google-chrome/urem.js: Added. * JSBench/google-firefox-win/urem.html: Added. * JSBench/google-firefox-win/urem.js: Added. * JSBench/google-firefox/uem.html: Added. * JSBench/google-firefox/uem.js: Added. * JSBench/google-safari/urem.html: Added. * JSBench/google-safari/urem.js: Added. * JSBench/harness.html: Added. * JSBench/harness.js: Added. * JSBench/harness.py: Added. * JSBench/index.html: Added. * JSBench/reload.html: Added. * JSBench/twitter-chrome-win/rem.html: Added. * JSBench/twitter-chrome-win/rem.js: Added. * JSBench/twitter-chrome/urem.html: Added. * JSBench/twitter-chrome/urem.js: Added. * JSBench/twitter-firefox-win/urem.html: Added. * JSBench/twitter-firefox-win/urem.js: Added. * JSBench/twitter-firefox/urem.html: Added. * JSBench/twitter-firefox/urem.js: Added. * JSBench/twitter-safari/urem.html: Added. * JSBench/twitter-safari/urem.js: Added. * JSBench/yahoo-chrome-win/urem.html: Added. * JSBench/yahoo-chrome-win/urem.js: Added. * JSBench/yahoo-chrome/urem.html: Added. * JSBench/yahoo-chrome/urem.js: Added. * JSBench/yahoo-firefox-win/urem.html: Added. * JSBench/yahoo-firefox-win/urem.js: Added. * JSBench/yahoo-firefox/urem.html: Added. * JSBench/yahoo-firefox/urem.js: Added. * JSBench/yahoo-safari/urem.html: Added. * JSBench/yahoo-safari/urem.js: Added. Tools: This changes the runner to use the layout of the newest version of JSBench. * Scripts/run-jsc-benchmarks: Canonical link: https://commits.webkit.org/176149@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201339 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-24 19:00:51 +00:00
/*
* Copyright (C) 2012 Purdue University
* Written by Gregor Richards
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
(function() {
/* This kind of test is very difficult to generalize, so we just avoid
* browsers known not to work */
var browserMin = {
"mozilla": "2.0",
"webkit": "536.7",
"v8": "10.0",
"msie": "9.0",
"opera": "11.60"
};
/* Since Chrome doesn't use the same JS engine as WebKit, it actually has
* different dependencies */
var rchrome = /Chrome[\/]([\w.]+)/;
var match = rchrome.exec(navigator.userAgent);
if (match) {
delete $.browser.webkit;
$.browser.v8 = true;
$.browser.version = match[1];
}
var browserName = {
"mozilla": "Mozilla",
"webkit": "WebKit",
"v8": "Chrome",
"msie": "Microsoft Internet Explorer",
"opera": "Opera"
};
var versionName = {
"mozilla": "2.0 (e.g. Firefox 4.0)"
};
var real = "harness.html";
// version-number-based comparison
function versionCheck(min, real) {
var minComps = min.split(".");
var realComps = real.split(".");
while (realComps.length < minComps.length) realComps.push("0");
for (var i = 0; i < minComps.length; i++) {
var min = parseInt(minComps[i]);
var real = parseInt(realComps[i]);
if (real < min) return false;
else if (real > min) return true;
}
return true;
}
// test the browser version
window.onload = function() {
var badBrowser = false;
var goodVersion = 0;
var badVersion = 0;
for (var browser in browserMin) {
var version = browserMin[browser];
if ($.browser[browser]) {
if (!versionCheck(version, $.browser.version)) {
badBrowser = browser;
goodVersion = version;
if (badBrowser in versionName) goodVersion = versionName[badBrowser];
badVersion = $.browser.version;
}
}
}
var output = document.getElementById("output");
if (badBrowser) {
// we don't like your browser
output.innerHTML =
"Sorry, but your browser is not supported. The minimum version of <b>" +
browserName[badBrowser] +
"</b> required to run these benchmarks is <b>" +
goodVersion +
"</b> (You are using <b>" +
badVersion +
"</b>). If you would like to attempt to run them anyway, <a href=\"" +
real +
"\">click here</a>, but it is highly likely that they will not " +
"run, and if they do, the results may be unreliable.";
} else {
output.innerHTML =
"Loading benchmarks ...";
window.location.href = real;
}
};
})();