Skip to content

Proposal: Group SunSpider into a single workload #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 20 additions & 26 deletions JetStreamDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -2368,34 +2368,28 @@ let BENCHMARKS = [
iterations: 15,
worstCaseCount: 2,
tags: ["Default", "Wasm", "dotnet"],
})
];


// SunSpider tests
const SUNSPIDER_TESTS = [
"3d-cube",
"3d-raytrace",
"base64",
"crypto-aes",
"crypto-md5",
"crypto-sha1",
"date-format-tofte",
"date-format-xparb",
"n-body",
"regex-dna",
"string-unpack-code",
"tagcloud",
];
for (const test of SUNSPIDER_TESTS) {
BENCHMARKS.push(new DefaultBenchmark({
name: `${test}-SP`,
files: [
`./SunSpider/${test}.js`
}),
new DefaultBenchmark({
name: `SunSpider`,
files: [
"./SunSpider/3d-cube.js",
"./SunSpider/3d-raytrace.js",
"./SunSpider/base64.js",
"./SunSpider/crypto-aes.js",
"./SunSpider/crypto-md5.js",
"./SunSpider/crypto-sha1.js",
"./SunSpider/date-format-tofte.js",
"./SunSpider/date-format-xparb.js",
"./SunSpider/n-body.js",
"./SunSpider/regex-dna.js",
"./SunSpider/string-unpack-code.js",
"./SunSpider/tagcloud.js",
`./SunSpider/benchmark.js`,
],
tags: ["Default", "SunSpider"],
}));
}
}),
];


// WTB (Web Tooling Benchmark) tests
const WTB_TESTS = [
Expand Down
16 changes: 5 additions & 11 deletions SunSpider/3d-cube.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// http://www.speich.net/computer/moztesting/3d.htm
// Created by Simon Speich

function run() {
function run3dCube() {
var Q = new Array();
var MTrans = new Array(); // transformation matrix
var MQube = new Array(); // position information of qube
Expand Down Expand Up @@ -340,10 +340,11 @@ function run() {
}
if (sum != validation[CubeSize])
throw "Error: bad vector sum for CubeSize = " + CubeSize + "; expected " + validation[CubeSize] + " but got " + sum;
return sum;
}

let result = 0xdeadbeef;
for ( var i = 20; i <= 160; i *= 2 ) {
Init(i);
result ^= Init(i);
}

Q = null;
Expand All @@ -354,12 +355,5 @@ function run() {
Testing = null;
LoopTime = null;
DisplArea = null;
}


class Benchmark {
runIteration() {
for (let i = 0; i < 8; ++i)
run();
}
return result;
}
10 changes: 2 additions & 8 deletions SunSpider/3d-raytrace.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

function run3dRayTrace() {
function createVector(x,y,z) {
return new Array(x,y,z);
}
Expand Down Expand Up @@ -438,18 +439,11 @@ for (var y = 0; y < size; y++) {\n\
return s;
}

function run() {
var testOutput = arrayToCanvasCommands(raytraceScene());

var expectedLength = 20970;

if (testOutput.length != expectedLength)
throw "Error: bad result: expected length " + expectedLength + " but got " + testOutput.length;
}

class Benchmark {
runIteration() {
for (let i = 0; i < 8; ++i)
run();
}
return testOutput.length;
}
11 changes: 2 additions & 9 deletions SunSpider/base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

// From: http://lxr.mozilla.org/mozilla/source/extensions/xml-rpc/src/nsXmlRpcClient.js#956

function runBase64() {
/* Convert data (an array of integers) to a Base64 string. */
var toBase64Table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var base64Pad = '=';
Expand Down Expand Up @@ -116,7 +117,6 @@ function base64ToString(data) {
return result;
}

function run() {
var str = "";

for ( var i = 0; i < 8192; i++ )
Expand All @@ -134,13 +134,6 @@ function run() {
// Double the string
str += str;
}
}


class Benchmark {
runIteration() {
for (let i = 0; i < 8; ++i)
run();
}
return str.length;
}

44 changes: 44 additions & 0 deletions SunSpider/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

/*
* 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 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 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.
*/


class Benchmark {
resultHash = 0;
runIteration() {
// this.resultHash ^= run3dCube() | 0;
// this.resultHash ^= run3dRayTrace() | 0;
// this.resultHash ^= runBase64() | 0;
// this.resultHash ^= runCryptoAES() | 0;
// this.resultHash ^= runCryptoMD5() | 0;
// this.resultHash ^= runCryptoSha1() | 0;
// this.resultHash ^= runDateFormatTofte() | 0;
// this.resultHash ^= runDateFormateXparb() | 0;
// this.resultHash ^= runNBody() | 0;
this.resultHash ^= runRegexpDNA() | 0;
// this.resultHash ^= runStringUnpackCode() | 0;
// this.resultHash ^= runTagcloud() | 0;
}
}
9 changes: 2 additions & 7 deletions SunSpider/crypto-aes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

function runCryptoAES() {
/*
* AES Cipher function: encrypt 'input' with Rijndael algorithm
*
Expand Down Expand Up @@ -381,7 +382,6 @@ function byteArrayToHexStr(b) { // convert byte array to hex string for display

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

function run() {
var plainText =
"ROMEO: But, soft! what light through yonder window breaks?\n\
It is the east, and Juliet is the sun.\n\
Expand Down Expand Up @@ -424,12 +424,7 @@ And sails upon the bosom of the air.";

if (decryptedText != plainText)
throw "ERROR: bad result: expected " + plainText + " but got " + decryptedText;
return decryptedText.length;
}


class Benchmark {
runIteration() {
for (let i = 0; i < 8; ++i)
run();
}
}
11 changes: 2 additions & 9 deletions SunSpider/crypto-md5.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* See http://pajhome.org.uk/crypt/md5 for more info.
*/

function runCryptoMD5() {
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
Expand Down Expand Up @@ -253,7 +254,6 @@ function binl2b64(binarray)
return str;
}

function run() {
var plainText =
"Rebellious subjects, enemies to peace,\n\
Profaners of this neighbour-stained steel,--\n\
Expand Down Expand Up @@ -289,13 +289,6 @@ Once more, on pain of death, all men depart.";

if (md5Output != expected)
throw "ERROR: bad result: expected " + expected + " but got " + md5Output;

return md5Output;
}


class Benchmark {
runIteration() {
for (let i = 0; i < 22; ++i)
run();
}
}
11 changes: 2 additions & 9 deletions SunSpider/crypto-sha1.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* See http://pajhome.org.uk/crypt/md5 for details.
*/

function runCryptoSha1() {
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
Expand Down Expand Up @@ -200,7 +201,6 @@ function binb2b64(binarray)
}


function run() {
var plainText =
"Two households, both alike in dignity,\n\
In fair Verona, where we lay our scene,\n\
Expand All @@ -226,12 +226,5 @@ What here shall miss, our toil shall strive to mend.";
var expected = "2524d264def74cce2498bf112bedf00e6c0b796d";
if (sha1Output != expected)
throw "ERROR: bad result: expected " + expected + " but got " + sha1Output;
}


class Benchmark {
runIteration() {
for (let i = 0; i < 25; ++i)
run();
}
return sha1Output;
}
18 changes: 1 addition & 17 deletions SunSpider/date-format-tofte.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
function runDateFormatTofte() {
Date.prototype.formatDate = function (input,time) {
// formatDate :
// a PHP date like function, for formatting date strings
Expand Down Expand Up @@ -303,7 +304,6 @@ Date.prototype.formatDate = function (input,time) {
return ia.join("");
}

function run() {
var date = new Date("1/1/2007 1:11:11");
var resultHash = 0x1a2b3c4d;

Expand All @@ -320,19 +320,3 @@ function run() {
// https://bugs.webkit.org/show_bug.cgi?id=114849
return resultHash;
}


class Benchmark {
EXPECTED_RESULT_HASH = 439041101;

runIteration() {
this.resultHash = 0x1a2b3c4d;
for (let i = 0; i < 8; ++i)
this.resultHash ^= run();
}

validate() {
if (this.resultHash != this.EXPECTED_RESULT_HASH)
throw new Error(`Got unexpected result hash ${this.resultHash} instead of ${this.EXPECTED_RESULT_HASH}`)
}
}
18 changes: 1 addition & 17 deletions SunSpider/date-format-xparb.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* details.
*/

function runDateFormateXparb() {
Date.parseFunctions = {count:0};
Date.parseRegexes = [];
Date.formatFunctions = {count:0};
Expand Down Expand Up @@ -408,7 +409,6 @@ Date.patterns = {
UniversalSortableDateTimePattern: "Y-m-d H:i:sO",
YearMonthPattern: "F, Y"};

function run() {
var date = new Date("1/1/2007 1:11:11");
var resultHash = 0x1a2b3c4d;

Expand All @@ -425,19 +425,3 @@ function run() {
// https://bugs.webkit.org/show_bug.cgi?id=114849
return resultHash;
}


class Benchmark {
EXPECTED_RESULT_HASH = 439041101;

runIteration() {
this.resultHash = 0x1a2b3c4d;
for (let i = 0; i < 8; ++i)
this.resultHash ^= run();
}

validate() {
if (this.resultHash != this.EXPECTED_RESULT_HASH)
throw new Error(`Got unexpected result hash ${this.resultHash} instead of ${this.EXPECTED_RESULT_HASH}`)
}
}
11 changes: 2 additions & 9 deletions SunSpider/n-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
http://shootout.alioth.debian.org/
contributed by Isaac Gouy */

function runNBody() {
var PI = 3.141592653589793;
var SOLAR_MASS = 4 * PI * PI;
var DAYS_PER_YEAR = 365.24;
Expand Down Expand Up @@ -151,7 +152,6 @@ NBodySystem.prototype.energy = function(){
return e;
}

function run() {
var ret = 0;

for ( var n = 3; n <= 24; n *= 2 ) {
Expand All @@ -172,12 +172,5 @@ function run() {
var expected = -1.3524862408537381;
if (ret != expected)
throw "ERROR: bad result: expected " + expected + " but got " + ret;
}


class Benchmark {
runIteration() {
for (let i = 0; i < 8; ++i)
run();
}
return ret;
}
Loading
Loading