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