+2007-10-14 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Darin.
+
+ - fixes for "New JavaScript benchmark"
+ http://bugs.webkit.org/show_bug.cgi?id=15515
+
+ * kjs/testkjs.cpp:
+ (TestFunctionImp::callAsFunction): Implement "load" for compatibility
+ with SpiderMonkey.
+ (TestFunctionImp::): ditto
+ (doIt): ditto
+ (kjsmain): Drop useless --> from output.
+
2007-10-15 Geoffrey Garen <ggaren@apple.com>
Removed unnecessary #include.
virtual bool implementsCall() const { return true; }
virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const List &args);
- enum { Print, Debug, Quit, GC, Version, Run };
+ enum { Print, Debug, Quit, GC, Version, Run, Load };
private:
int id;
{
switch (id) {
case Print:
- printf("--> %s\n", args[0]->toString(exec).UTF8String().c_str());
+ printf("%s\n", args[0]->toString(exec).UTF8String().c_str());
return jsUndefined();
case Debug:
fprintf(stderr, "--> %s\n", args[0]->toString(exec).UTF8String().c_str());
StopWatch stopWatch;
char* fileName = strdup(args[0]->toString(exec).UTF8String().c_str());
char* script = createStringWithContentsOfFile(fileName);
- if (!script)
+ if (!script) {
+ free(fileName);
return throwError(exec, GeneralError, "Could not open file.");
+ }
stopWatch.start();
exec->dynamicInterpreter()->evaluate(fileName, 0, script);
return jsNumber(stopWatch.getElapsedMS());
}
+ case Load:
+ {
+ char* fileName = strdup(args[0]->toString(exec).UTF8String().c_str());
+ char* script = createStringWithContentsOfFile(fileName);
+ if (!script) {
+ free(fileName);
+ return throwError(exec, GeneralError, "Could not open file.");
+ }
+
+ exec->dynamicInterpreter()->evaluate(fileName, 0, script);
+
+ free(script);
+ free(fileName);
+
+ return jsUndefined();
+ }
case Quit:
exit(0);
default:
// add "version" for compatibility with the mozilla js shell
global->put(interp->globalExec(), "version", new TestFunctionImp(TestFunctionImp::Version, 1));
global->put(interp->globalExec(), "run", new TestFunctionImp(TestFunctionImp::Run, 1));
+ global->put(interp->globalExec(), "load", new TestFunctionImp(TestFunctionImp::Load, 1));
Interpreter::setShouldPrintExceptions(true);
Collector::collect();
#endif
- if (success)
- fprintf(stderr, "OK.\n");
-
#ifdef KJS_DEBUG_MEM
Interpreter::finalCheck();
#endif
--- /dev/null
+2007-10-14 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Darin.
+
+ - New JavaScript benchmark
+ http://bugs.webkit.org/show_bug.cgi?id=15515
+
+ A start on a new JavaScript benchmark, with standalone and
+ browser-hosted drivers.
+
+ The test content is still incomplete and the drivers could use
+ some more features but there is enough here to make a good start.
+
+ The drivers compute a 95% confidence interval on the mean for the
+ whole test, each category, and each individual test to make it
+ easier to tell whether differences are statistically
+ significant. The confidence interval can be narrowed by running
+ the test more times.
+
+ * TODO: Added. Remaining things that need to be done.
+ * sunspider: Added. Perl script that acts as the standalone test driver.
+ * resources/sunspider-standalone-driver.js: Added. JavaScript part
+ of standalone test driver.
+ * resources/sunspider-analyze-results.js: Added. JavaScript statistical
+ analysis code.
+ * resources/TEMPLATE.html: Added. Template for browser-hosted tests.
+ * make-hosted: Added. Script to generate browser-hosted tests.
+ * hosted/sunspider.html: Added. Start page for browser-hosted test.
+ * hosted/sunspider-driver.html: Added. Driver for browser-hosted tests.
+ * hosted/sunspider-results.html: Added. Results page for browser-hosted
+ tests.
+ * hosted/sunspider-record-result.js: Added. Helper file for browser-hosted
+ tests.
+ * tests/LIST: Added. List of tests to use.
+ * tests/bitops-3bit-bits-in-byte.js: Added. Some initial test content.
+ * tests/bitops-bits-in-byte.js: Added. Ditto.
+ * tests/bitops-bitwise-and.js: Added. Ditto.
+ * tests/math-cordic.js: Added. Ditto.
+
--- /dev/null
+
+* Add more test cases. Categories we'd like to cover (with reasonably
+ real-world tests, preferably not microbenchmarks) include:
+
+ - math (general)
+ - bitops
+ - 3-d (the math bits)
+ - crypto / encoding
+ - string processing
+ - regexps
+ - date processing
+ - array processing
+ - control flow
+ - function calls / recursion
+ - object access (unclear if it is possible to make a realistic
+ benchmark that isolates this)
+
+ I'd specifically like to add all the computer language shootout
+ tests that Mozilla is using.
+
+* Normalize tests. Most of the test cases available have a repeat
+ count of some sort, so the time they take can be tuned. The tests
+ should be tuned so that each category contributes about the same
+ total, and so each test in each category contributes about the same
+ amount. The question is, what implementation should be the baseline?
+ My current thought is to either pick some specific browser on a
+ specific platform (IE 7 or Firefox 2 perhaps), or try to target the
+ average that some set of same-generation release browsers get on
+ each test. The latter is more work. IE7 is probably a reasonable
+ normalization target since it is the latest version of the most
+ popular browser, so results on this benchmark will tell you how much
+ you have to gain or lose by using a different browser.
+
+* Add support to compare two different engines (or two builds of the
+ same engine) interleaved.
+
+* Add support to compare two existing sets of saved results.
+
+* Allow repeat count to be controlled from the browser-hosted version
+ and the WebKitTools wrapper script.
+
+* Add support to run only a subset of the tests (both command-line and
+ web versions).
+
+* Add a profile mode for the command-line version that runs the tests
+ repeatedly in the same command-line interpreter instance, for ease
+ of profiling.
+
+* Make the browser-hosted version prettier, both in general design and
+ maybe using bar graphs for the output.
+
+* Make it possible to track change over time and generate a graph per
+ result showing result and error bar for each version.
+
+* Hook up to automated testing / buildbot infrastructure.
+
+* Possibly... add the ability to download iBench from its original
+ server, pull out the JS test content, preprocess it, and add it as a
+ category to the benchmark.
+
+* Profit.
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<!--
+ Copyright (C) 2007 Apple Inc. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
+-->
+
+<title>SunSpider JavaScript Benchmark In Progress...</title>
+</head>
+<body>
+
+<h2>SunSpider JavaScript Benchmark In Progress...</h2>
+
+<script src="sunspider-test-prefix.js"></script>
+<script>
+var testIndex = -1;
+var currentRepeat = 0;
+var repeatCount = 5;
+
+var output = [];
+output.length = repeatCount;
+for (var i = 0; i < output.length; i++) {
+ output[i] = {};
+}
+
+function next()
+{
+ window.setTimeout(reallyNext, 500);
+}
+
+function reallyNext()
+{
+ testIndex++;
+ if (testIndex < tests.length) {
+ document.getElementById("testframe").src = tests[testIndex] + ".html";
+ } else if (++currentRepeat < repeatCount) {
+ testIndex = 0;
+ document.getElementById("testframe").src = tests[testIndex] + ".html";
+ } else {
+ finish();
+ }
+}
+
+function recordResult(time)
+{
+ output[currentRepeat][tests[testIndex]] = time;
+}
+
+function finish()
+{
+ var outputString = "[";
+ for (var i = 0; i < output.length; i++) {
+ outputString += "{";
+ for (var test in output[i]) {
+ outputString += '"' + test + '":' + output[i][test] + ",";
+ }
+ outputString = outputString.substring(0, outputString.length - 1);
+ outputString += "},";
+ }
+ outputString = outputString.substring(0, outputString.length - 1);
+ outputString += "]";
+
+ location = "sunspider-results.html?" + encodeURI(outputString);
+}
+
+</script>
+
+<iframe id="testframe" onload="next()" width="80%" height="500">
+</iframe>
+
+</body>
+</html>
--- /dev/null
+/*
+ * Copyright (C) 2007 Apple Inc. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 record(time) {
+ document.getElementById("console").innerHTML = time + "ms";
+ if (window.parent) {
+ parent.recordResult(time);
+ }
+}
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<!--
+ Copyright (C) 2007 Apple Inc. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
+-->
+
+<title>SunSpider JavaScript Benchmark Results</title>
+</head>
+<body>
+<h2>SunSpider JavaScript Benchmark Results</h2>
+
+<pre id="console">
+</pre>
+
+<a href="sunspider-driver.html">Run Again</a>
+
+<script>
+var output = eval(decodeURI(location.search.substring(1)));
+function print(str) {
+ document.getElementById("console").appendChild(document.createTextNode(str + "\n"));
+}
+</script>
+
+<script src="sunspider-test-prefix.js"></script>
+<script src="sunspider-analyze-results.js"></script>
+
+</body>
+</html>
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<!--
+ Copyright (C) 2007 Apple Inc. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
+-->
+
+<title>SunSpider JavaScript Benchmark</title>
+</head>
+<body>
+<h2>SunSpider JavaScript Benchmark</h2>
+
+<a href="sunspider-driver.html">Start Now</a>
+</body>
+</html>
--- /dev/null
+#!/usr/bin/perl -w
+
+# Copyright (C) 2007 Apple Inc. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
+
+use strict;
+
+open TEMPLATE, "<resources/TEMPLATE.html";
+my $template = do { local $/; <TEMPLATE> };
+close TEMPLATE;
+
+my @tests = ();
+my @categories = ();
+my %uniqueCategories = ();
+
+open TESTLIST, "<./tests/LIST";
+while (<TESTLIST>) {
+ chomp;
+ next unless $_;
+ push @tests, $_;
+ my $category = $_;
+ $category =~ s/-.*//;
+ if (!$uniqueCategories{$category}) {
+ push @categories, $category;
+ $uniqueCategories{$category} = $category;
+ }
+}
+close TESTLIST;
+
+for my $test (@tests) {
+ my $name = "${test}";
+
+ open SCRIPT, "<tests/${test}.js";
+ my $script = do { local $/; <SCRIPT> };
+ close SCRIPT;
+
+ my $output = $template;
+ $output =~ s/\@NAME\@/${name}/g;
+ $output =~ s/\@SCRIPT\@/${script}/g;
+
+ open OUTPUT, ">hosted/${test}.html";
+ print OUTPUT $output;
+ close OUTPUT;
+}
+
+
+my $prefix = "var tests = [ " . join(", ", map { '"' . $_ . '"' } @tests) . " ];\n";
+$prefix .= "var categories = [ " . join(", ", map { '"' . $_ . '"' } @categories) . " ];\n";
+
+open PREFIX, ">hosted/sunspider-test-prefix.js";
+print PREFIX $prefix;
+close PREFIX;
+
+system("cp resources/sunspider-analyze-results.js hosted");
+
+print "hosted/sunspider.html is ready to use.\n";
--- /dev/null
+<!DOCTYPE html>
+<head>
+<!--
+ Copyright (C) 2007 Apple Inc. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
+-->
+
+<title>SunSpider @NAME@</title>
+</head>
+<body>
+<h3>@NAME@</h3>
+<div id="console">
+</div>
+<script src="sunspider-record-result.js"></script>
+<script>
+
+var _sunSpiderStartDate = new Date();
+
+@SCRIPT@
+
+var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
+
+record(_sunSpiderInterval);
+</script>
+
+
+</body>
+</html>
--- /dev/null
+/*
+ * Copyright (C) 2007 Apple Inc. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
+ */
+
+var count = output.length;
+
+var itemTotals = {};
+itemTotals.length = count;
+
+var total = 0;
+var categoryTotals = {};
+var testTotalsByCategory = {};
+
+var mean = 0;
+var categoryMeans = {};
+var testMeansByCategory = {};
+
+var stdDev = 0;
+var categoryStdDevs = {};
+var testStdDevsByCategory = {};
+
+var stdErr = 0;
+var categoryStdErrs = {};
+var testStdErrsByCategory = {};
+
+function initialize()
+{
+ itemTotals = {total: []};
+
+ for (var i = 0; i < categories.length; i++) {
+ var category = categories[i];
+ itemTotals[category] = [];
+ categoryTotals[category] = 0;
+ testTotalsByCategory[category] = {};
+ categoryMeans[category] = 0;
+ testMeansByCategory[category] = {};
+ categoryStdDevs[category] = 0;
+ testStdDevsByCategory[category] = {};
+ categoryStdErrs[category] = 0;
+ testStdErrsByCategory[category] = {};
+ }
+
+ for (var i = 0; i < tests.length; i++) {
+ var test = tests[i];
+ itemTotals[test] = [];
+ var category = test.replace(/-.*/, "");
+ testTotalsByCategory[category][test] = 0;
+ testMeansByCategory[category][test] = 0;
+ testStdDevsByCategory[category][test] = 0;
+ testStdErrsByCategory[category][test] = 0;
+ }
+
+ for (var i = 0; i < count; i++) {
+ itemTotals["total"][i] = 0;
+ for (var category in categoryTotals) {
+ itemTotals[category][i] = 0;
+ for (var test in testTotalsByCategory[category]) {
+ itemTotals[test][i] = 0;
+ }
+ }
+ }
+}
+
+function computeItemTotals()
+{
+ for (var i = 0; i < output.length; i++) {
+ var result = output[i];
+ for (var test in result) {
+ var time = result[test];
+ var category = test.replace(/-.*/, "");
+ itemTotals["total"][i] += time;
+ itemTotals[category][i] += time;
+ itemTotals[test][i] += time;
+ }
+ }
+}
+
+function computeTotals()
+{
+ for (var i = 0; i < output.length; i++) {
+ var result = output[i];
+ for (var test in result) {
+ var time = result[test];
+ var category = test.replace(/-.*/, "");
+ total += time;
+ categoryTotals[category] += time;
+ testTotalsByCategory[category][test] += time;
+ }
+ }
+}
+
+function computeMeans()
+{
+ mean = total / count;
+ for (var category in categoryTotals) {
+ categoryMeans[category] = categoryTotals[category] / count;
+ for (var test in testTotalsByCategory[category]) {
+ testMeansByCategory[category][test] = testTotalsByCategory[category][test] / count;
+ }
+ }
+}
+
+function standardDeviation(mean, items)
+{
+ var deltaSquaredSum = 0;
+ for (var i = 0; i < items.length; i++) {
+ var delta = items[i] - mean;
+ deltaSquaredSum += delta * delta;
+ }
+ variance = deltaSquaredSum / items.length;
+ return Math.sqrt(variance);
+}
+
+function computeStdDevs()
+{
+ stdDev = standardDeviation(mean, itemTotals["total"]);
+ for (var category in categoryStdDevs) {
+ categoryStdDevs[category] = standardDeviation(categoryMeans[category], itemTotals[category]);
+ }
+ for (var category in categoryStdDevs) {
+ for (var test in testStdDevsByCategory[category]) {
+ testStdDevsByCategory[category][test] = standardDeviation(testMeansByCategory[category][test], itemTotals[test]);
+ }
+ }
+}
+
+function computeStdErrors()
+{
+ var sqrtCount = Math.sqrt(count);
+
+ stdErr = stdDev / sqrtCount;
+ for (var category in categoryStdErrs) {
+ categoryStdErrs[category] = categoryStdDevs[category] / sqrtCount;
+ }
+ for (var category in categoryStdDevs) {
+ for (var test in testStdErrsByCategory[category]) {
+ testStdErrsByCategory[category][test] = testStdDevsByCategory[category][test] / sqrtCount;
+ }
+ }
+
+}
+
+function formatResult(meanWidth, mean, stdErr)
+{
+ var meanString = mean.toFixed(1).toString();
+ while (meanString.length < meanWidth) {
+ meanString = " " + meanString;
+ }
+
+ return meanString + "ms " + "[ +/- " + (1.96 * stdErr).toFixed(2) + "ms | +/- " + ((1.96 * stdErr / mean) * 100).toFixed(2) + "% ]";
+}
+
+function computeLabelWidth()
+{
+ var width = "Total".length;
+ for (var category in categoryMeans) {
+ if (category.length + 2 > width)
+ width = category.length + 2;
+ }
+ for (var i = 0; i < tests.length; i++) {
+ var shortName = tests[i].replace(/^[^-]*-/, "");
+ if (shortName.length + 4 > width)
+ width = shortName.length + 4;
+ }
+
+ return width;
+}
+
+function computeMeanWidth()
+{
+ var width = mean.toFixed(1).toString().length;
+ for (var category in categoryMeans) {
+ var candidate = categoryMeans[category].toFixed(2).toString().length;
+ if (candidate > width)
+ width = candidate;
+ for (var test in testMeansByCategory[category]) {
+ var candidate = testMeansByCategory[category][test].toFixed(2).toString().length;
+ if (candidate > width)
+ width = candidate;
+ }
+ }
+
+ return width;
+}
+
+function resultLine(labelWidth, indent, label, meanWidth, mean, stdErr)
+{
+ var result = "";
+ for (i = 0; i < indent; i++) {
+ result += " ";
+ }
+
+ result += label + ": ";
+
+ for (i = 0; i < (labelWidth - (label.length + indent)); i++) {
+ result += " ";
+ }
+
+ return result + formatResult(meanWidth, mean, stdErr);
+}
+
+function printOutput()
+{
+ var labelWidth = computeLabelWidth();
+ var meanWidth = computeMeanWidth();
+
+ print("\n");
+ print("========================================");
+ print("RESULTS (means and 95% confidence intervals)");
+ print("----------------------------------------");
+ print(resultLine(labelWidth, 0, "Total", meanWidth, mean, stdErr));
+ print("----------------------------------------");
+ for (var category in categoryMeans) {
+ print(resultLine(labelWidth, 2, category, meanWidth, categoryMeans[category], categoryStdErrs[category]));
+ for (var test in testMeansByCategory[category]) {
+ var shortName = test.replace(/^[^-]*-/, "");
+ print(resultLine(labelWidth, 4, shortName, meanWidth, testMeansByCategory[category][test], testStdErrsByCategory[category][test]));
+ }
+ }
+}
+
+initialize();
+computeItemTotals();
+computeTotals();
+computeMeans();
+computeStdDevs();
+computeStdErrors();
+printOutput();
--- /dev/null
+/*
+ * Copyright (C) 2007 Apple Inc. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
+ */
+
+var results = new Array();
+
+var time = 0;
+var times = [];
+times.length = tests.length;
+
+for (var j = 0; j < tests.length; j++) {
+ var testName = "tests/" + tests[j] + ".js";
+ var startTime = new Date;
+ load(testName);
+ times[j] = new Date() - startTime;
+}
+
+function recordResults(tests, times)
+{
+ var output = "{\n";
+
+ for (j = 0; j < tests.length; j++) {
+ output += ' "' + tests[j] + '": ' + times[j] + ',\n';
+ }
+ output = output.substring(0, output.length - 2) + "\n";
+
+ output += "}";
+ print(output);
+}
+
+recordResults(tests, times);
--- /dev/null
+#!/usr/bin/perl -w
+
+# Copyright (C) 2007 Apple Inc. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
+
+use strict;
+
+sub usage()
+{
+ die "Usage: sunspider engine [ max_runs ]\n";
+}
+
+if (scalar @ARGV < 1) {
+ usage();
+}
+
+my $jsshell = $ARGV[0];
+
+my $max = $ARGV[1];
+$max = 5 if !$max;
+
+if ($max =~ /\D/) {
+ usage();
+}
+
+print STDERR "Running SunSpider once for warmup, then $max times\n";
+
+my @tests = ();
+my @categories = ();
+my %uniqueCategories = ();
+
+open TESTLIST, "<./tests/LIST";
+while (<TESTLIST>) {
+ chomp;
+ next unless $_;
+ push @tests, $_;
+ my $category = $_;
+ $category =~ s/-.*//;
+ if (!$uniqueCategories{$category}) {
+ push @categories, $category;
+ $uniqueCategories{$category} = $category;
+ }
+}
+close TESTLIST;
+
+my $prefix = "var tests = [ " . join(", ", map { '"' . $_ . '"' } @tests) . " ];\n";
+$prefix .= "var categories = [ " . join(", ", map { '"' . $_ . '"' } @categories) . " ];\n";
+
+open PREFIX, ">/tmp/sunspider-test-prefix.js";
+print PREFIX $prefix;
+close PREFIX;
+
+my $discard = `$jsshell -f /tmp/sunspider-test-prefix.js -f resources/sunspider-standalone-driver.js 2> /dev/null`;
+
+print "Discarded first run.\n";
+
+my $result;
+my $count = 0;
+my @results = ();
+my $total = 0;
+while ($count++ < $max) {
+ $result = `$jsshell -f /tmp/sunspider-test-prefix.js -f resources/sunspider-standalone-driver.js 2> /dev/null`;
+ chomp $result;
+ push @results, $result;
+ print $result . "\n";
+}
+
+my $output = "var output = [\n" . join(",\n", @results) . "\n];\n";
+
+open(OUTPUT, ">/tmp/sunspider-results.js");
+print OUTPUT $output;
+close(OUTPUT);
+
+system("$jsshell -f /tmp/sunspider-test-prefix.js -f /tmp/sunspider-results.js -f resources/sunspider-analyze-results.js");
+
--- /dev/null
+math-cordic
+bitops-bits-in-byte
+bitops-3bit-bits-in-byte
+bitops-bitwise-and
+
--- /dev/null
+// Copyright (c) 2004 by Arthur Langereis (arthur_ext at domain xfinitegames, tld com
+
+// 1 op = 6 ANDs, 3 SHRs, 3 SHLs, 4 assigns, 2 ADDs
+// O(1)
+function fast3bitlookup(b) {
+var c, bi3b = 0xE994; // 0b1110 1001 1001 0100; // 3 2 2 1 2 1 1 0
+c = 3 & (bi3b >> ((b << 1) & 14));
+c += 3 & (bi3b >> ((b >> 2) & 14));
+c += 3 & (bi3b >> ((b >> 5) & 6));
+return c;
+
+/*
+lir4,0xE994; 9 instructions, no memory access, minimal register dependence, 6 shifts, 2 adds, 1 inline assign
+rlwinmr5,r3,1,28,30
+rlwinmr6,r3,30,28,30
+rlwinmr7,r3,27,29,30
+rlwnmr8,r4,r5,30,31
+rlwnmr9,r4,r6,30,31
+rlwnmr10,r4,r7,30,31
+addr3,r8,r9
+addr3,r3,r10
+*/
+}
+
+
+function TimeFunc(func) {
+var x, y, t;
+for(var x=0; x<1000; x++)
+for(var y=0; y<256; y++) func(y);
+}
+
+TimeFunc(fast3bitlookup);
--- /dev/null
+// Copyright (c) 2004 by Arthur Langereis (arthur_ext at domain xfinitegames, tld com)
+
+
+// 1 op = 2 assigns, 16 compare/branches, 8 ANDs, (0-8) ADDs, 8 SHLs
+// O(n)
+function bitsinbyte(b) {
+var m = 1, c = 0;
+while(m<0x100) {
+if(b & m) c++;
+m <<= 1;
+}
+return c;
+}
+
+function TimeFunc(func) {
+var x, y, t;
+for(var x=0; x<500; x++)
+for(var y=0; y<256; y++) func(y);
+}
+
+TimeFunc(bitsinbyte);
--- /dev/null
+/*
+ * Copyright (C) 2007 Apple Inc. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
+ */
+
+var x = 4294967296;
+for (var i = 0; i < 1000000; i++)
+ x = x & i;
--- /dev/null
+// Copyright (C) 2007 Rich Moore
+
+/////. Start CORDIC
+
+var AG_CONST = 0.6072529350;
+
+function FIXED(X)
+{
+ return X * 65536.0;
+}
+
+function FLOAT(X)
+{
+ return X / 65536.0;
+}
+
+function DEG2RAD(X)
+{
+ return 0.017453 * (X);
+}
+
+var Angles = [
+ FIXED(45.0), FIXED(26.565), FIXED(14.0362), FIXED(7.12502),
+ FIXED(3.57633), FIXED(1.78991), FIXED(0.895174), FIXED(0.447614),
+ FIXED(0.223811), FIXED(0.111906), FIXED(0.055953),
+ FIXED(0.027977)
+ ];
+
+
+function cordicsincos() {
+ var X;
+ var Y;
+ var TargetAngle;
+ var CurrAngle;
+ var Step;
+
+ X = FIXED(AG_CONST); /* AG_CONST * cos(0) */
+ Y = 0; /* AG_CONST * sin(0) */
+
+ TargetAngle = FIXED(28.027);
+ CurrAngle = 0;
+ for (Step = 0; Step < 12; Step++) {
+ var NewX;
+ if (TargetAngle > CurrAngle) {
+ NewX = X - (Y >> Step);
+ Y = (X >> Step) + Y;
+ X = NewX;
+ CurrAngle += Angles[Step];
+ } else {
+ NewX = X + (Y >> Step);
+ Y = -(X >> Step) + Y;
+ X = NewX;
+ CurrAngle -= Angles[Step];
+ }
+ }
+}
+
+///// End CORDIC
+
+function cordic( runs ) {
+ var start = new Date();
+
+ for ( var i = 0 ; i < runs ; i++ ) {
+ cordicsincos();
+ }
+
+ var end = new Date();
+
+ return end.getTime() - start.getTime();
+}
+
+cordic(30000);
+2007-10-14 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Darin.
+
+ - New JavaScript benchmark
+ http://bugs.webkit.org/show_bug.cgi?id=15515
+
+ * Scripts/run-sunspider: Added. Wrapper to run sunspider on the
+ current development or release build of JavaScriptCore.
+
2007-10-15 Mark Rowe <mrowe@apple.com>
Reviewed by Sam.
--- /dev/null
+#!/usr/bin/perl -w
+
+# Copyright (C) 2007 Apple Inc. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
+
+use strict;
+use FindBin;
+use lib $FindBin::Bin;
+use webkitdirs;
+use POSIX;
+
+
+# determine configuration
+my $configuration;
+setConfiguration();
+$configuration = configuration();
+
+my @xcodeArgs;
+my $root;
+
+# pre-evaluate arguments. jsDriver args have - preceding, xcode args do not.
+# special arguments
+# --root=<path to webkit root> use pre-built root
+# --gtk build gtk
+foreach my $arg(@ARGV) {
+ print $arg."\n";
+ if( $arg =~ /root=(.*)/ ){
+ $root = $1;
+ } elsif( $arg =~ /^--gtk$/i ){
+ } else {
+ push( @xcodeArgs, $arg );
+ }
+}
+
+setConfigurationProductDir(Cwd::abs_path($root)) if (defined($root));
+
+# Find JavaScriptCore directory
+chdirWebKit();
+chdir("JavaScriptCore");
+
+#compile TestKJS
+my @options = XcodeOptions();
+my $result;
+if (!defined($root)){
+ if (isOSX()) {
+ $result = system "xcodebuild", "-project", "JavaScriptCore.xcodeproj", "-target", "testkjs", @options, @xcodeArgs;
+ }elsif (isCygwin()) {
+ $result = buildVisualStudioProject("JavaScriptCore.vcproj/JavaScriptCore.sln");
+ }
+ exit WEXITSTATUS($result) if WEXITSTATUS($result);
+}
+
+my $productDir = productDir();
+
+$productDir .= "/JavaScriptCore" if (isQt() or isGtk());
+$ENV{DYLD_FRAMEWORK_PATH} = $productDir;
+
+my $testkjsName;
+sub determineTestkjsName
+{
+ return if $testkjsName;
+ if (isCygwin() && ($configuration eq "Debug")) {
+ $testkjsName = "testkjs_debug";
+ } else {
+ $testkjsName = "testkjs";
+ }
+}
+$testkjsName = determineTestkjsName();
+
+chdirWebKit();
+chdir("SunSpider");
+
+exec "./sunspider", "$productDir/$testkjsName";