Debian Codegraph @

rhino/testsrc/tests/js1_5/Array/regress-474529.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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 var gTestfile = 'regress-474529.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 474529;
9 var summary = 'Do not assert: _buf->_nextPage';
10 var actual = '';
11 var expect = '';
12
13
14 //-----------------------------------------------------------------------------
15 test();
16 //-----------------------------------------------------------------------------
17
18 function test()
19 {
20 enterFunc ('test');
21 printBugNumber(BUGNUMBER);
22 printStatus (summary);
23
24 function main() {
25
26 function timeit(N, buildArrayString) {
27 return Function("N",
28 "var d1 = +new Date;" +
29 "while (N--) var x = " + buildArrayString +
30 "; return +new Date - d1")(N);
31 }
32
33 function reportResults(size, N, literalMs, newArrayMs, arrayMs) {
34 print(Array.join(arguments, "\t"));
35 }
36
37 var repetitions = [ 9000, 7000, 4000, 2000, 2000, 2000, 800, 800, 800, 300, 100, 100 ]
38 for (var zeros = "0, ", i = 0; i < repetitions.length; ++i) {
39 var N = repetitions[i];
40 reportResults((1 << i) + 1, N,
41 timeit(N, "[" + zeros + " 0 ]"),
42 timeit(N, "new Array(" + zeros + " 0)"),
43 timeit(N, "Array(" + zeros + " 0)"));
44 zeros += zeros;
45 }
46 }
47
48 jit(true);
49 gc();
50 print("Size\t\Rep.\t\Literal\tnew Arr\tArray()");
51 print("====\t=====\t=======\t=======\t=======");
52 main();
53 jit(false);
54
55 reportCompare(expect, actual, summary);
56
57 exitFunc ('test');
58 }