Tue, 16 Aug 2016 21:41:28 -0700
Added tag jdk8u102-b33 for changeset 36e3c21b5fca
jlaskey@3 | 1 | /* |
jlaskey@7 | 2 | * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
jlaskey@3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jlaskey@475 | 4 | * |
jlaskey@3 | 5 | * This code is free software; you can redistribute it and/or modify it |
jlaskey@3 | 6 | * under the terms of the GNU General Public License version 2 only, as |
jlaskey@3 | 7 | * published by the Free Software Foundation. |
jlaskey@475 | 8 | * |
jlaskey@3 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jlaskey@3 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jlaskey@3 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jlaskey@3 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
jlaskey@3 | 13 | * accompanied this code). |
jlaskey@475 | 14 | * |
jlaskey@3 | 15 | * You should have received a copy of the GNU General Public License version |
jlaskey@3 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
jlaskey@3 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jlaskey@475 | 18 | * |
jlaskey@3 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
jlaskey@3 | 20 | * or visit www.oracle.com if you need additional information or have any |
jlaskey@3 | 21 | * questions. |
jlaskey@3 | 22 | */ |
jlaskey@3 | 23 | |
jlaskey@3 | 24 | /** |
jlaskey@3 | 25 | * runsunspider : runs the sunspider tests and checks for compliance |
jlaskey@3 | 26 | * |
attila@963 | 27 | * @test |
attila@963 | 28 | * @option -timezone=PST |
attila@963 | 29 | * @runif external.sunspider |
jlaskey@3 | 30 | */ |
jlaskey@3 | 31 | |
jlaskey@3 | 32 | /** |
jlaskey@3 | 33 | * This is not a test, but a test "framework" for running sunspider tests. |
jlaskey@3 | 34 | */ |
jlaskey@3 | 35 | |
jlaskey@3 | 36 | function assertEq(a, b) { |
jlaskey@3 | 37 | if (a !== b) { |
jlaskey@475 | 38 | throw "ASSERTION FAILED: " + a + " should be " + b; |
jlaskey@3 | 39 | } |
jlaskey@3 | 40 | } |
jlaskey@3 | 41 | |
attila@963 | 42 | function pprint(x) { |
attila@963 | 43 | if (verbose_run) { |
attila@963 | 44 | print(x); |
attila@963 | 45 | } |
attila@963 | 46 | } |
attila@963 | 47 | |
jlaskey@3 | 48 | var runs = 0; |
jlaskey@3 | 49 | var total_time = 0; |
jlaskey@3 | 50 | |
jlaskey@3 | 51 | function runbench(name) { |
jlaskey@3 | 52 | var filename = name.split("/").pop(); |
attila@963 | 53 | pprint("Running (warmup/sanity) " + filename); |
jlaskey@3 | 54 | |
jlaskey@3 | 55 | var start = new Date; |
attila@963 | 56 | load(name); |
attila@963 | 57 | |
jlaskey@3 | 58 | var stop = new Date - start; |
jlaskey@3 | 59 | total_time += stop; |
jlaskey@475 | 60 | |
attila@963 | 61 | pprint(filename + " done in " + stop + " ms"); |
jlaskey@3 | 62 | runs++; |
jlaskey@3 | 63 | } |
lagergren@20 | 64 | |
attila@963 | 65 | var m_w; |
attila@963 | 66 | var m_z; |
attila@963 | 67 | var MAXINT; |
lagergren@20 | 68 | |
lagergren@20 | 69 | //produce deterministic random numbers for test suite |
lagergren@20 | 70 | function pseudorandom() { |
lagergren@20 | 71 | m_z = 36969 * (m_z & 65535) + (m_z >> 16); |
lagergren@20 | 72 | m_w = 18000 * (m_w & 65535) + (m_w >> 16); |
lagergren@20 | 73 | return (Math.abs((m_z << 16) + m_w) & MAXINT) / MAXINT; |
lagergren@20 | 74 | } |
lagergren@20 | 75 | |
attila@963 | 76 | function initrandom() { |
attila@963 | 77 | m_w = 4711; |
attila@963 | 78 | m_z = 17; |
attila@963 | 79 | MAXINT = 0x7fffffff; |
attila@963 | 80 | Math.random = pseudorandom; |
attila@963 | 81 | } |
attila@963 | 82 | |
attila@963 | 83 | var rtimes = 0; |
attila@963 | 84 | var dir = (typeof(__DIR__) == 'undefined') ? "test/script/basic/" : __DIR__; |
attila@963 | 85 | var single; |
attila@963 | 86 | var verbose_run = false; |
attila@963 | 87 | var runall = false; |
attila@963 | 88 | |
attila@963 | 89 | var args = []; |
attila@963 | 90 | if (typeof $ARGS !== 'undefined') { |
attila@963 | 91 | args = $ARGS; |
attila@963 | 92 | } else if (typeof arguments !== 'undefined' && arguments.length != 0) { |
attila@963 | 93 | args = arguments; |
attila@963 | 94 | } |
attila@963 | 95 | |
attila@963 | 96 | for (var i = 0; i < args.length; i++) { |
attila@963 | 97 | if (args[i] === '--verbose') { |
attila@963 | 98 | verbose_run = true; |
attila@963 | 99 | } else if (args[i] === '--times') { |
attila@963 | 100 | i++; |
attila@963 | 101 | rtimes = +args[i]; |
attila@963 | 102 | } else if (args[i] === '--single') { |
attila@963 | 103 | i++; |
attila@963 | 104 | single = args[i]; |
attila@963 | 105 | } else if (args[i] === '--runall') { |
attila@963 | 106 | i++; |
attila@963 | 107 | runall = true; |
attila@963 | 108 | } |
attila@963 | 109 | } |
attila@963 | 110 | |
lagergren@20 | 111 | function runsuite(tests) { |
attila@963 | 112 | var changed = false; |
attila@963 | 113 | var res = []; |
lagergren@20 | 114 | var oldRandom = Math.random; |
jlaskey@475 | 115 | |
jlaskey@3 | 116 | try { |
attila@963 | 117 | for (var n = 0; n < tests.length; n++) { |
attila@963 | 118 | try { |
attila@963 | 119 | path = dir + '../external/sunspider/tests/sunspider-1.0.2/' + tests[n].name |
attila@963 | 120 | |
attila@963 | 121 | initrandom(); |
attila@963 | 122 | |
attila@963 | 123 | var dd = new Date; |
attila@963 | 124 | |
attila@963 | 125 | runbench(path); |
attila@963 | 126 | if (typeof tests[n].actual !== 'undefined') { |
attila@963 | 127 | assertEq(tests[n].actual(), tests[n].expected()); |
attila@963 | 128 | } |
attila@963 | 129 | |
attila@963 | 130 | var times = 0; |
attila@963 | 131 | if (typeof tests[n].rerun !== 'undefined' && tests[n].times > 0) { |
attila@963 | 132 | pprint("rerunning " + tests[n].name + " " + tests[n].times + " times..."); |
attila@963 | 133 | var to = tests[n].times; |
attila@963 | 134 | |
attila@963 | 135 | var elemsPerPercent = to / 100; |
attila@963 | 136 | var po = 0|(to / 10); |
attila@963 | 137 | |
attila@963 | 138 | pprint("Doing warmup."); |
attila@963 | 139 | for (times = 0; times < to; times++) { |
attila@963 | 140 | initrandom(); |
attila@963 | 141 | tests[n].rerun(); |
attila@963 | 142 | } |
attila@963 | 143 | |
attila@963 | 144 | pprint("Doing hot runs."); |
attila@963 | 145 | for (times = 0; times < to; times++) { |
attila@963 | 146 | initrandom(); |
attila@963 | 147 | tests[n].rerun(); |
attila@963 | 148 | if ((times % (po|0)) == 0) { |
attila@963 | 149 | pprint("\t" + times/to * 100 + "%"); |
attila@963 | 150 | } |
attila@963 | 151 | } |
attila@963 | 152 | } |
attila@963 | 153 | |
attila@963 | 154 | var t = Math.round(((new Date - dd) / (times == 0 ? 1 : times)) * 100 / 100); |
attila@963 | 155 | pprint("time per iteration: " + t + " ms"); |
attila@963 | 156 | if (typeof tests[n].actual !== 'undefined') { |
attila@963 | 157 | assertEq(tests[n].actual(), tests[n].expected()); |
attila@963 | 158 | } |
attila@963 | 159 | res.push(t); |
attila@963 | 160 | |
attila@963 | 161 | pprint(""); |
attila@963 | 162 | |
attila@963 | 163 | changed = true; |
attila@963 | 164 | } catch(e) { |
attila@963 | 165 | if (runall) { |
attila@963 | 166 | print("FAIL!"); |
attila@963 | 167 | } else { |
attila@963 | 168 | throw e; |
attila@963 | 169 | } |
jlaskey@475 | 170 | } |
jlaskey@475 | 171 | } |
attila@963 | 172 | } catch (e) { |
attila@963 | 173 | print("FAIL!"); |
attila@963 | 174 | throw e; |
jlaskey@475 | 175 | // no scripting or something, silently fail |
lagergren@20 | 176 | } finally { |
attila@963 | 177 | Math.random = oldRandom; |
jlaskey@3 | 178 | } |
attila@963 | 179 | |
attila@963 | 180 | for (var n = 0; n < tests.length; n++) { |
attila@963 | 181 | |
attila@963 | 182 | var time = "" + res[n]; |
attila@963 | 183 | while (time.length < 6) { |
attila@963 | 184 | time = " " + time; |
attila@963 | 185 | } |
attila@963 | 186 | time += " ms"; |
attila@963 | 187 | if (res[n] == -1) { |
attila@963 | 188 | time = "<couldn't be rerun>"; |
attila@963 | 189 | } |
attila@963 | 190 | var str = tests[n].name; |
attila@963 | 191 | for (var spaces = str.length; spaces < 32; spaces++) { |
attila@963 | 192 | str += " "; |
attila@963 | 193 | } |
attila@963 | 194 | str += " "; |
attila@963 | 195 | str += time; |
attila@963 | 196 | |
attila@963 | 197 | if (tests[n].times > 0) { |
attila@963 | 198 | str += " ["; |
attila@963 | 199 | str += tests[n].times + " reruns]"; |
attila@963 | 200 | } |
attila@963 | 201 | pprint(str); |
attila@963 | 202 | } |
lagergren@20 | 203 | |
jlaskey@3 | 204 | return changed; |
jlaskey@3 | 205 | } |
jlaskey@3 | 206 | |
lagergren@20 | 207 | function hash(str) { |
lagergren@20 | 208 | var s = "" + str; |
lagergren@20 | 209 | var h = 0; |
lagergren@20 | 210 | var off = 0; |
lagergren@20 | 211 | for (var i = 0; i < s.length; i++) { |
jlaskey@475 | 212 | h = 31 * h + s.charCodeAt(off++); |
jlaskey@475 | 213 | h &= 0x7fffffff; |
lagergren@20 | 214 | } |
lagergren@20 | 215 | return h ^ s.length; |
lagergren@20 | 216 | } |
jlaskey@3 | 217 | |
jlaskey@3 | 218 | var tests = [ |
attila@963 | 219 | |
attila@963 | 220 | { name: 'regexp-dna.js', |
attila@963 | 221 | actual: function() { |
attila@963 | 222 | return dnaOutputString + dnaInput; |
attila@963 | 223 | }, |
attila@963 | 224 | expected: function() { |
attila@963 | 225 | return expectedDNAOutputString + expectedDNAInput; |
attila@963 | 226 | }, |
attila@963 | 227 | }, |
attila@963 | 228 | |
lagergren@20 | 229 | { name: 'string-base64.js', |
jlaskey@475 | 230 | actual: function() { |
jlaskey@475 | 231 | return hash(str); |
lagergren@20 | 232 | }, |
lagergren@20 | 233 | expected: function() { |
jlaskey@475 | 234 | return 1544571068; |
attila@963 | 235 | }, |
attila@963 | 236 | times: rtimes, |
attila@963 | 237 | rerun: function() { |
attila@963 | 238 | toBinaryTable = [ |
attila@963 | 239 | -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, |
attila@963 | 240 | -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, |
attila@963 | 241 | -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63, |
attila@963 | 242 | 52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1, 0,-1,-1, |
attila@963 | 243 | -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14, |
attila@963 | 244 | 15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1, |
attila@963 | 245 | -1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40, |
attila@963 | 246 | 41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1 |
attila@963 | 247 | ]; |
attila@963 | 248 | var str = ""; |
attila@963 | 249 | for (var i = 0; i < 8192; i++) |
attila@963 | 250 | str += String.fromCharCode((25 * Math.random()) + 97); |
attila@963 | 251 | |
attila@963 | 252 | for (var i = 8192; i <= 16384; i *= 2) { |
attila@963 | 253 | var base64; |
attila@963 | 254 | base64 = toBase64(str); |
attila@963 | 255 | var encoded = base64ToString(base64); |
attila@963 | 256 | |
attila@963 | 257 | str += str; |
lagergren@20 | 258 | } |
attila@963 | 259 | toBinaryTable = null; |
lagergren@20 | 260 | } |
jlaskey@475 | 261 | }, |
lagergren@20 | 262 | { name: 'date-format-xparb.js', |
jlaskey@475 | 263 | actual: function() { |
jlaskey@475 | 264 | return shortFormat + longFormat; |
lagergren@20 | 265 | }, |
lagergren@20 | 266 | expected: function() { |
jlaskey@475 | 267 | return "2017-09-05Tuesday, September 05, 2017 8:43:48 AM"; |
attila@963 | 268 | }, |
attila@963 | 269 | times: rtimes, |
attila@963 | 270 | rerun: function() { |
attila@963 | 271 | date = new Date("1/1/2007 1:11:11"); |
attila@963 | 272 | for (i = 0; i < 4000; ++i) { |
attila@963 | 273 | var shortFormat = date.dateFormat("Y-m-d"); |
attila@963 | 274 | var longFormat = date.dateFormat("l, F d, Y g:i:s A"); |
attila@963 | 275 | date.setTime(date.getTime() + 84266956); |
lagergren@20 | 276 | } |
attila@963 | 277 | } |
attila@963 | 278 | |
attila@963 | 279 | }, |
attila@963 | 280 | { name: 'string-validate-input.js', |
attila@963 | 281 | actual: function() { |
attila@963 | 282 | return hash(endResult); |
attila@963 | 283 | }, |
attila@963 | 284 | expected: function() { |
attila@963 | 285 | return 726038055; |
attila@963 | 286 | }, |
attila@963 | 287 | times: rtimes, |
attila@963 | 288 | rerun: function() { |
attila@963 | 289 | doTest(); |
attila@963 | 290 | }, |
jlaskey@475 | 291 | }, |
lagergren@20 | 292 | { name: '3d-morph.js', |
lagergren@20 | 293 | actual: function() { |
jlaskey@475 | 294 | var acceptableDelta = 4e-15; |
jlaskey@475 | 295 | return (testOutput - 6.394884621840902e-14) < acceptableDelta; |
lagergren@20 | 296 | }, |
lagergren@20 | 297 | expected: function() { |
jlaskey@475 | 298 | return true; |
attila@963 | 299 | }, |
attila@963 | 300 | times: rtimes, |
attila@963 | 301 | rerun: function() { |
attila@963 | 302 | a = Array() |
attila@963 | 303 | for (var i=0; i < nx*nz*3; ++i) |
attila@963 | 304 | a[i] = 0 |
attila@963 | 305 | for (var i = 0; i < loops; ++i) { |
attila@963 | 306 | morph(a, i/loops) |
attila@963 | 307 | } |
attila@963 | 308 | testOutput = 0; |
attila@963 | 309 | for (var i = 0; i < nx; i++) |
attila@963 | 310 | testOutput += a[3*(i*nx+i)+1]; |
attila@963 | 311 | a = null; |
attila@963 | 312 | |
lagergren@20 | 313 | } |
jlaskey@475 | 314 | }, |
lagergren@20 | 315 | { name: 'crypto-aes.js', |
lagergren@20 | 316 | actual: function() { |
jlaskey@475 | 317 | return plainText; |
lagergren@20 | 318 | }, |
lagergren@20 | 319 | expected: function() { |
jlaskey@475 | 320 | return decryptedText; |
attila@963 | 321 | }, |
attila@963 | 322 | times: rtimes, |
attila@963 | 323 | rerun: function() { |
attila@963 | 324 | cipherText = AESEncryptCtr(plainText, password, 256); |
attila@963 | 325 | decryptedText = AESDecryptCtr(cipherText, password, 256); |
attila@963 | 326 | |
lagergren@20 | 327 | } |
jlaskey@475 | 328 | }, |
lagergren@20 | 329 | { name: 'crypto-md5.js', |
lagergren@20 | 330 | actual: function() { |
jlaskey@475 | 331 | return md5Output; |
lagergren@20 | 332 | }, |
lagergren@20 | 333 | expected: function() { |
jlaskey@475 | 334 | return "a831e91e0f70eddcb70dc61c6f82f6cd"; |
attila@963 | 335 | }, |
attila@963 | 336 | times: rtimes, |
attila@963 | 337 | rerun: function() { |
attila@963 | 338 | md5Output = hex_md5(plainText); |
lagergren@20 | 339 | } |
jlaskey@475 | 340 | }, |
attila@963 | 341 | |
lagergren@20 | 342 | { name: 'crypto-sha1.js', |
lagergren@20 | 343 | actual: function() { |
jlaskey@475 | 344 | return sha1Output; |
lagergren@20 | 345 | }, |
lagergren@20 | 346 | expected: function() { |
jlaskey@475 | 347 | return "2524d264def74cce2498bf112bedf00e6c0b796d"; |
attila@963 | 348 | }, |
attila@963 | 349 | times: rtimes, |
attila@963 | 350 | rerun: function() { |
attila@963 | 351 | sha1Output = hex_sha1(plainText); |
lagergren@20 | 352 | } |
jlaskey@475 | 353 | }, |
attila@963 | 354 | |
jlaskey@475 | 355 | { name: 'bitops-bitwise-and.js', |
lagergren@20 | 356 | actual: function() { |
jlaskey@475 | 357 | return result; |
lagergren@20 | 358 | }, |
lagergren@20 | 359 | expected: function() { |
jlaskey@475 | 360 | return 0; |
attila@963 | 361 | }, |
attila@963 | 362 | times: rtimes, |
attila@963 | 363 | rerun: function() { |
attila@963 | 364 | bitwiseAndValue = 4294967296; |
attila@963 | 365 | for (var i = 0; i < 600000; i++) { |
attila@963 | 366 | bitwiseAndValue = bitwiseAndValue & i; |
attila@963 | 367 | } |
attila@963 | 368 | result = bitwiseAndValue; |
lagergren@20 | 369 | } |
jlaskey@475 | 370 | }, |
attila@963 | 371 | |
jlaskey@475 | 372 | { name: 'bitops-bits-in-byte.js', |
lagergren@20 | 373 | actual: function() { |
jlaskey@475 | 374 | return result; |
lagergren@20 | 375 | }, |
lagergren@20 | 376 | expected: function() { |
jlaskey@475 | 377 | return 358400; |
attila@963 | 378 | }, |
attila@963 | 379 | times: rtimes, |
attila@963 | 380 | rerun: function() { |
attila@963 | 381 | result = TimeFunc(bitsinbyte); |
lagergren@20 | 382 | } |
jlaskey@475 | 383 | }, |
attila@963 | 384 | |
jlaskey@475 | 385 | { name: 'bitops-nsieve-bits.js', |
lagergren@20 | 386 | actual: function() { |
jlaskey@475 | 387 | var ret = 0; |
jlaskey@475 | 388 | for (var i = 0; i < result.length; ++i) { |
jlaskey@475 | 389 | ret += result[i]; |
jlaskey@475 | 390 | } |
jlaskey@475 | 391 | ret += result.length; |
jlaskey@475 | 392 | return ret; |
lagergren@20 | 393 | }, |
lagergren@20 | 394 | expected: function() { |
jlaskey@475 | 395 | return -1286749539853; |
attila@963 | 396 | }, |
attila@963 | 397 | times: rtimes, |
attila@963 | 398 | rerun: function() { |
attila@963 | 399 | result = sieve(); |
lagergren@20 | 400 | } |
jlaskey@475 | 401 | }, |
attila@963 | 402 | |
jlaskey@475 | 403 | { name: 'bitops-3bit-bits-in-byte.js', |
lagergren@20 | 404 | actual: function() { |
jlaskey@475 | 405 | return sum; |
lagergren@20 | 406 | }, |
lagergren@20 | 407 | expected: function() { |
jlaskey@475 | 408 | return 512000; |
attila@963 | 409 | }, |
attila@963 | 410 | times: rtimes, |
attila@963 | 411 | rerun: function() { |
attila@963 | 412 | sum = TimeFunc(fast3bitlookup); |
lagergren@20 | 413 | } |
jlaskey@475 | 414 | }, |
attila@963 | 415 | |
jlaskey@475 | 416 | { name: 'access-nbody.js', |
lagergren@20 | 417 | actual: function() { |
jlaskey@475 | 418 | return ret; |
lagergren@20 | 419 | }, |
lagergren@20 | 420 | expected: function() { |
jlaskey@624 | 421 | return -1.3524862408537381; |
attila@963 | 422 | }, |
attila@963 | 423 | times: rtimes, |
attila@963 | 424 | rerun: function() { |
attila@963 | 425 | var ret = 0; |
attila@963 | 426 | for (var n = 3; n <= 24; n *= 2) { |
attila@963 | 427 | (function(){ |
attila@963 | 428 | var bodies = new NBodySystem( Array( |
attila@963 | 429 | Sun(),Jupiter(),Saturn(),Uranus(),Neptune() |
attila@963 | 430 | )); |
attila@963 | 431 | var max = n * 100; |
attila@963 | 432 | |
attila@963 | 433 | ret += bodies.energy(); |
attila@963 | 434 | for (var i=0; i<max; i++){ |
attila@963 | 435 | bodies.advance(0.01); |
attila@963 | 436 | } |
attila@963 | 437 | ret += bodies.energy(); |
attila@963 | 438 | })(); |
attila@963 | 439 | } |
lagergren@20 | 440 | } |
jlaskey@475 | 441 | }, |
attila@963 | 442 | |
jlaskey@475 | 443 | { name: 'access-binary-trees.js', |
lagergren@20 | 444 | actual: function() { |
jlaskey@475 | 445 | return ret; |
lagergren@20 | 446 | }, |
lagergren@20 | 447 | expected: function() { |
jlaskey@624 | 448 | return -4; |
attila@963 | 449 | }, |
attila@963 | 450 | times: rtimes, |
attila@963 | 451 | rerun: function() { |
attila@963 | 452 | ret = 0; |
attila@963 | 453 | |
attila@963 | 454 | for (var n = 4; n <= 7; n += 1) { |
attila@963 | 455 | var minDepth = 4; |
attila@963 | 456 | var maxDepth = Math.max(minDepth + 2, n); |
attila@963 | 457 | var stretchDepth = maxDepth + 1; |
attila@963 | 458 | |
attila@963 | 459 | var check = bottomUpTree(0,stretchDepth).itemCheck(); |
attila@963 | 460 | |
attila@963 | 461 | var longLivedTree = bottomUpTree(0,maxDepth); |
attila@963 | 462 | for (var depth=minDepth; depth<=maxDepth; depth+=2){ |
attila@963 | 463 | var iterations = 1 << (maxDepth - depth + minDepth); |
attila@963 | 464 | |
attila@963 | 465 | check = 0; |
attila@963 | 466 | for (var i=1; i<=iterations; i++){ |
attila@963 | 467 | check += bottomUpTree(i,depth).itemCheck(); |
attila@963 | 468 | check += bottomUpTree(-i,depth).itemCheck(); |
attila@963 | 469 | } |
attila@963 | 470 | } |
attila@963 | 471 | |
attila@963 | 472 | ret += longLivedTree.itemCheck(); |
attila@963 | 473 | } |
lagergren@20 | 474 | } |
jlaskey@475 | 475 | }, |
attila@963 | 476 | |
lagergren@20 | 477 | { name: 'access-fannkuch.js', |
lagergren@20 | 478 | actual: function() { |
jlaskey@475 | 479 | return ret; |
lagergren@20 | 480 | }, |
lagergren@20 | 481 | expected: function() { |
jlaskey@475 | 482 | return 22; |
attila@963 | 483 | }, |
attila@963 | 484 | times: rtimes, |
attila@963 | 485 | rerun: function() { |
attila@963 | 486 | n = 8; |
attila@963 | 487 | ret = fannkuch(n); |
lagergren@20 | 488 | } |
lagergren@20 | 489 | }, |
attila@963 | 490 | |
lagergren@20 | 491 | { name: 'math-spectral-norm.js', |
jlaskey@475 | 492 | actual: function() { |
jlaskey@475 | 493 | var ret = ''; |
jlaskey@475 | 494 | for (var i = 6; i <= 48; i *= 2) { |
jlaskey@475 | 495 | ret += spectralnorm(i) + ','; |
jlaskey@475 | 496 | } |
jlaskey@475 | 497 | return ret; |
lagergren@20 | 498 | }, |
lagergren@20 | 499 | expected: function() { |
jlaskey@475 | 500 | return "1.2657786149754053,1.2727355112619148,1.273989979775574,1.274190125290389,"; |
attila@963 | 501 | }, |
attila@963 | 502 | times: rtimes, |
attila@963 | 503 | rerun: function() { |
attila@963 | 504 | total = 0; |
attila@963 | 505 | for (var i = 6; i <= 48; i *= 2) { |
attila@963 | 506 | total += spectralnorm(i); |
attila@963 | 507 | } |
lagergren@20 | 508 | } |
jlaskey@475 | 509 | }, |
attila@963 | 510 | |
lagergren@20 | 511 | { name: '3d-raytrace.js', |
lagergren@20 | 512 | actual: function() { |
jlaskey@475 | 513 | return hash(testOutput); |
lagergren@20 | 514 | }, |
lagergren@20 | 515 | expected: function() { |
jlaskey@475 | 516 | return 230692593; |
attila@963 | 517 | }, |
attila@963 | 518 | times: rtimes, |
attila@963 | 519 | rerun: function() { |
attila@963 | 520 | testOutput = arrayToCanvasCommands(raytraceScene()); |
lagergren@20 | 521 | } |
jlaskey@475 | 522 | }, |
attila@963 | 523 | |
lagergren@20 | 524 | { name: 'math-cordic.js', |
lagergren@20 | 525 | actual: function() { |
jlaskey@475 | 526 | return total; |
lagergren@20 | 527 | }, |
lagergren@20 | 528 | expected: function() { |
jlaskey@475 | 529 | return 10362.570468755888; |
attila@963 | 530 | }, |
attila@963 | 531 | times: rtimes, |
attila@963 | 532 | rerun: function() { |
attila@963 | 533 | total = 0; |
attila@963 | 534 | cordic(25000); |
lagergren@20 | 535 | } |
lagergren@20 | 536 | }, |
attila@963 | 537 | |
lagergren@20 | 538 | { name: 'controlflow-recursive.js', |
lagergren@20 | 539 | actual: function() { |
jlaskey@475 | 540 | var ret = 0; |
jlaskey@475 | 541 | for (var i = 3; i <= 5; i++) { |
jlaskey@475 | 542 | ret += ack(3,i); |
jlaskey@475 | 543 | ret += fib(17.0+i); |
jlaskey@475 | 544 | ret += tak(3*i+3,2*i+2,i+1); |
jlaskey@475 | 545 | } |
jlaskey@475 | 546 | return ret; |
lagergren@20 | 547 | }, |
lagergren@20 | 548 | expected: function() { |
jlaskey@475 | 549 | return 57775; |
attila@963 | 550 | }, |
attila@963 | 551 | times: rtimes, |
attila@963 | 552 | rerun: function() { |
attila@963 | 553 | result = 0; |
attila@963 | 554 | for (var i = 3; i <= 5; i++) { |
attila@963 | 555 | result += ack(3,i); |
attila@963 | 556 | result += fib(17.0+i); |
attila@963 | 557 | result += tak(3*i+3,2*i+2,i+1); |
attila@963 | 558 | } |
lagergren@20 | 559 | } |
jlaskey@475 | 560 | }, |
attila@963 | 561 | |
lagergren@20 | 562 | { name: 'date-format-tofte.js', |
lagergren@20 | 563 | actual: function() { |
jlaskey@475 | 564 | return shortFormat + longFormat; |
lagergren@20 | 565 | }, |
lagergren@20 | 566 | expected: function() { |
jlaskey@475 | 567 | return "2008-05-01Thursday, May 01, 2008 6:31:22 PM"; |
attila@963 | 568 | }, |
attila@963 | 569 | times: rtimes, |
attila@963 | 570 | rerun: function() { |
attila@963 | 571 | date = new Date("1/1/2007 1:11:11"); |
attila@963 | 572 | for (i = 0; i < 500; ++i) { |
attila@963 | 573 | var shortFormat = date.formatDate("Y-m-d"); |
attila@963 | 574 | var longFormat = date.formatDate("l, F d, Y g:i:s A"); |
attila@963 | 575 | date.setTime(date.getTime() + 84266956); |
attila@963 | 576 | } |
lagergren@20 | 577 | } |
lagergren@20 | 578 | }, |
attila@963 | 579 | |
lagergren@20 | 580 | { name: 'string-tagcloud.js', |
lagergren@20 | 581 | actual: function() { |
jlaskey@475 | 582 | // The result string embeds floating-point numbers, which can vary a bit on different platforms, |
jlaskey@475 | 583 | // so we truncate them a bit before comparing. |
jlaskey@475 | 584 | var tagcloud_norm = tagcloud.replace(/([0-9.]+)px/g, function(str, p1) { return p1.substr(0, 10) + 'px' }) |
jlaskey@475 | 585 | return tagcloud_norm.length; |
lagergren@20 | 586 | }, |
lagergren@20 | 587 | expected: function() { |
jlaskey@475 | 588 | return 295906; |
attila@963 | 589 | }, |
attila@963 | 590 | times: rtimes, |
attila@963 | 591 | rerun: function() { |
attila@963 | 592 | tagInfo = tagInfoJSON.parseJSON(function(a, b) { if (a == "popularity") { return Math.log(b) / log2; } else {return b; } }); |
attila@963 | 593 | tagcloud = makeTagCloud(tagInfo); |
lagergren@20 | 594 | } |
jlaskey@475 | 595 | }, |
attila@963 | 596 | |
attila@963 | 597 | { name: 'math-partial-sums.js', |
attila@963 | 598 | actual: function() { |
attila@963 | 599 | return total; |
attila@963 | 600 | }, |
attila@963 | 601 | expected: function() { |
attila@963 | 602 | return 60.08994194659945; |
attila@963 | 603 | }, |
attila@963 | 604 | times: rtimes, |
attila@963 | 605 | rerun: function() { |
attila@963 | 606 | total = 0; |
attila@963 | 607 | for (var i = 1024; i <= 16384; i *= 2) { |
attila@963 | 608 | total += partial(i); |
attila@963 | 609 | } |
attila@963 | 610 | } |
attila@963 | 611 | }, |
attila@963 | 612 | |
attila@963 | 613 | { name: 'access-nsieve.js', |
attila@963 | 614 | actual: function() { |
attila@963 | 615 | return result; |
attila@963 | 616 | }, |
attila@963 | 617 | expected: function() { |
attila@963 | 618 | return 14302; |
attila@963 | 619 | }, |
attila@963 | 620 | times: rtimes, |
attila@963 | 621 | rerun: function() { |
attila@963 | 622 | result = sieve(); |
attila@963 | 623 | } |
attila@963 | 624 | }, |
attila@963 | 625 | |
attila@963 | 626 | { name: '3d-cube.js', |
attila@963 | 627 | times: rtimes, |
attila@963 | 628 | rerun: function() { |
attila@963 | 629 | Q = new Array(); |
attila@963 | 630 | MTrans = new Array(); // transformation matrix |
attila@963 | 631 | MQube = new Array(); // position information of qube |
attila@963 | 632 | I = new Array(); // entity matrix |
attila@963 | 633 | Origin = new Object(); |
attila@963 | 634 | Testing = new Object(); |
attila@963 | 635 | for ( var i = 20; i <= 160; i *= 2 ) { |
attila@963 | 636 | Init(i); |
attila@963 | 637 | } |
attila@963 | 638 | } |
attila@963 | 639 | }, |
attila@963 | 640 | |
attila@963 | 641 | //TODO no easy way to sanity check result |
attila@963 | 642 | { name: 'string-fasta.js', |
attila@963 | 643 | times: rtimes, |
attila@963 | 644 | rerun: function() { |
attila@963 | 645 | ret = 0; |
attila@963 | 646 | count = 7; |
attila@963 | 647 | fastaRepeat(2*count*100000, ALU); |
attila@963 | 648 | fastaRandom(3*count*1000, IUB); |
attila@963 | 649 | fastaRandom(5*count*1000, HomoSap); |
attila@963 | 650 | } |
attila@963 | 651 | }, |
attila@963 | 652 | |
attila@963 | 653 | //TODO no easy way to sanity check result |
lagergren@20 | 654 | { name: 'string-unpack-code.js', |
lagergren@20 | 655 | actual: function() { |
jlaskey@475 | 656 | return decompressedMochiKit.length == 106415 && |
jlaskey@475 | 657 | decompressedMochiKit[2000] == '5' && |
jlaskey@475 | 658 | decompressedMochiKit[12000] == '_' && |
jlaskey@475 | 659 | decompressedMochiKit[82556] == '>'; |
lagergren@20 | 660 | }, |
lagergren@20 | 661 | expected: function() { |
attila@963 | 662 | return true; |
attila@963 | 663 | }, |
jlaskey@475 | 664 | }, |
attila@963 | 665 | |
lagergren@20 | 666 | ]; |
jlaskey@3 | 667 | |
attila@963 | 668 | tests.sort(function(a,b) { return a.name.localeCompare(b.name); }); |
attila@963 | 669 | if (typeof single !== 'undefined') { |
attila@963 | 670 | for (i in tests) { |
attila@963 | 671 | if (tests[i].name === single) { |
attila@963 | 672 | singleTest = tests[i]; |
attila@963 | 673 | tests = [singleTest]; |
attila@963 | 674 | break; |
attila@963 | 675 | } |
attila@963 | 676 | } |
attila@963 | 677 | if (tests.length != 1) { |
attila@963 | 678 | throw "unknown single test '" + single + "'"; |
attila@963 | 679 | } |
attila@963 | 680 | } |
attila@963 | 681 | |
attila@963 | 682 | |
jlaskey@3 | 683 | // handle the case this script may be run by a JS engine that doesn't |
jlaskey@3 | 684 | // support __DIR__ global variable. |
jlaskey@3 | 685 | |
lagergren@20 | 686 | runsuite(tests); |
jlaskey@3 | 687 | |
attila@963 | 688 | pprint('\n' + runs + "/" + tests.length + " tests were successfully run in " + total_time + " ms "); |
jlaskey@3 | 689 | |
jlaskey@3 | 690 | print("Sunspider finished!"); |