regress-474529.js (1700B)
1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 //----------------------------------------------------------------------------- 7 var BUGNUMBER = 474529; 8 var summary = 'Do not assert: _buf->_nextPage'; 9 var actual = ''; 10 var expect = ''; 11 12 13 //----------------------------------------------------------------------------- 14 test(); 15 //----------------------------------------------------------------------------- 16 17 function test() 18 { 19 printBugNumber(BUGNUMBER); 20 printStatus (summary); 21 22 function main() { 23 24 function timeit(N, buildArrayString) { 25 return Function("N", 26 "var d1 = +new Date;" + 27 "while (N--) var x = " + buildArrayString + 28 "; return +new Date - d1")(N); 29 } 30 31 function reportResults(size, N, literalMs, newArrayMs, arrayMs) { 32 print(Array.prototype.join.call(arguments, "\t")); 33 } 34 35 var repetitions = [ 9000, 7000, 4000, 2000, 2000, 2000, 800, 800, 800, 300, 100, 100 ] 36 for (var zeros = "0, ", i = 0; i < repetitions.length; ++i) { 37 var N = repetitions[i]; 38 reportResults((1 << i) + 1, N, 39 timeit(N, "[" + zeros + " 0 ]"), 40 timeit(N, "new Array(" + zeros + " 0)"), 41 timeit(N, "Array(" + zeros + " 0)")); 42 zeros += zeros; 43 } 44 } 45 46 gc(); 47 print("Size\t\Rep.\t\Literal\tnew Arr\tArray()"); 48 print("====\t=====\t=======\t=======\t======="); 49 main(); 50 51 reportCompare(expect, actual, summary); 52 }