Debian Codegraph @

rhino/testsrc/tests/js1_5/extensions/regress-347306-02.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-347306-02.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 347306;
9 var summary = 'toSource should not be O(N**2)';
10 var actual = '';
11 var expect = '';
12
13 printBugNumber(BUGNUMBER);
14 printStatus (summary);
15
16 var data = {X:[], Y:[]};
17 for (var size = 1000; size <= 10000; size += 1000)
18 {
19 data.X.push(size);
20 data.Y.push(testSource(size));
21 }
22
23 var order = BigO(data);
24
25 var msg = '';
26 for (var p = 0; p < data.X.length; p++)
27 {
28 msg += '(' + data.X[p] + ', ' + data.Y[p] + '); ';
29 }
30 printStatus(msg);
31 printStatus('Order: ' + order);
32 reportCompare(true, order < 2, 'BigO ' + order + ' < 2');
33
34 function testSource(n)
35 {
36 var funtext = "";
37
38 for (var i=0; i<n; ++i)
39 funtext += "alert(" + i + "); ";
40
41 var fun = new Function(funtext);
42
43 var start = new Date();
44
45 var s = fun.toSource();
46
47 var end = new Date();
48
49 print("Size: " + n + ", Time: " + (end - start) + " ms");
50
51 return end - start;
52 }