js/src/tests/js1_5/Regress/regress-416628.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // |reftest| random -- BigO
michael@0 2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 //-----------------------------------------------------------------------------
michael@0 8 var BUGNUMBER = 416628;
michael@0 9 var summary = 'O(n^2) blowup due to overlong cx->tempPool arena list';
michael@0 10 var actual = '';
michael@0 11 var expect = '';
michael@0 12
michael@0 13 //-----------------------------------------------------------------------------
michael@0 14 test();
michael@0 15 //-----------------------------------------------------------------------------
michael@0 16
michael@0 17 function test()
michael@0 18 {
michael@0 19 enterFunc ('test');
michael@0 20 printBugNumber(BUGNUMBER);
michael@0 21 printStatus (summary);
michael@0 22
michael@0 23 var data = {X:[], Y:[]};
michael@0 24
michael@0 25 Function.prototype.inherits = function(parentCtor) {
michael@0 26 moo_inherits(this, parentCtor);
michael@0 27 };
michael@0 28
michael@0 29 moo_inherits = function(childCtor, parentCtor) {
michael@0 30 /** @constructor */
michael@0 31 function tempCtor() {};
michael@0 32 tempCtor.prototype = parentCtor.prototype;
michael@0 33 childCtor.superClass_ = parentCtor.prototype;
michael@0 34 childCtor.prototype = new tempCtor();
michael@0 35 childCtor.prototype.constructor = childCtor;
michael@0 36 };
michael@0 37
michael@0 38 var jstart = 100;
michael@0 39 var jstop = 1000;
michael@0 40 var jinterval = (jstop - jstart)/9;
michael@0 41
michael@0 42 if (true) {
michael@0 43 for (var j = jstart; j < jstop; j += jinterval)
michael@0 44 {
michael@0 45 data.X.push(j);
michael@0 46 var code = '';
michael@0 47 for (var i = 0; i < j; i++)
michael@0 48 {
michael@0 49 code += createCode(i);
michael@0 50 }
michael@0 51 gc();
michael@0 52 var start = new Date();
michael@0 53 eval(code);
michael@0 54 var stop = new Date();
michael@0 55 data.Y.push(stop - start);
michael@0 56 }
michael@0 57 }
michael@0 58
michael@0 59 var order = BigO(data);
michael@0 60
michael@0 61 var msg = '';
michael@0 62 for (var p = 0; p < data.X.length; p++)
michael@0 63 {
michael@0 64 msg += '(' + data.X[p] + ', ' + data.Y[p] + '); ';
michael@0 65 }
michael@0 66 printStatus(msg);
michael@0 67 printStatus('Order: ' + order);
michael@0 68
michael@0 69 reportCompare(true, order < 2, 'BigO ' + order + ' < 2');
michael@0 70
michael@0 71 exitFunc ('test');
michael@0 72 }
michael@0 73
michael@0 74 function createCode(i)
michael@0 75 {
michael@0 76 var code = '';
michael@0 77
michael@0 78 code += "var str1_" + i + "='This is 1 a test " + i + " string.';";
michael@0 79 code += "var str2_" + i + "='This is 2 a test " + i + " string.';";
michael@0 80 code += "var str3_" + i + "='This is 3 a test " + i + " string.';";
michael@0 81 code += "var str4_" + i + "='This is 4 a test " + i + " string.';";
michael@0 82 code += "var str5_" + i + "='This is 5 a test " + i + " string.';";
michael@0 83 code += "var str6_" + i + "='This is 6 a test " + i + " string.';";
michael@0 84 code += "var str7_" + i + "='This is 7 a test " + i + " string.';";
michael@0 85 code += "";
michael@0 86 code += "var base" + i + " = function() {this.a_=4;this.b_=5};";
michael@0 87 code += "base" + i + ".f1 = function() {this.a_=4;this.b_=5};";
michael@0 88 code += "base" + i + ".prototype.f2 = function() {this.a_=4;this.b_=5};";
michael@0 89 code += "base" + i + ".prototype.f3 = function() {this.a_=4;this.b_=5};";
michael@0 90 code += "base" + i + ".prototype.f4 = function() {this.a_=4;this.b_=5};";
michael@0 91 code += "base" + i + ".prototype.f5 = function() {this.a_=4;this.b_=5};";
michael@0 92 code += "";
michael@0 93 code += "var child" + i + " = function() {this.a_=4;this.b_=5};";
michael@0 94 code += "child" + i + ".inherits(base" + i + ");";
michael@0 95 code += "child" + i + ".f1 = function() {this.a_=4;this.b_=5};";
michael@0 96 code += "child" + i + ".prototype.f2 = function() {this.a_=4;this.b_=5};";
michael@0 97 code += "child" + i + ".prototype.f3 = function() {this.a_=4;this.b_=5};";
michael@0 98 code += "child" + i + ".prototype.f4 = function() {this.a_=4;this.b_=5};";
michael@0 99 code += "child" + i + ".prototype.f5 = function() {this.a_=4;this.b_=5};";
michael@0 100 code += "";
michael@0 101 code += "var gchild" + i + " = function() {this.a_=4;this.b_=5};";
michael@0 102 code += "gchild" + i + ".inherits(child" + i + ");";
michael@0 103 code += "gchild" + i + ".f1 = function() {this.a_=4;this.b_=5};";
michael@0 104 code += "gchild" + i + ".prototype.f2 = function() {this.a_=4;this.b_=5};";
michael@0 105 code += "gchild" + i + ".prototype.f3 = function() {this.a_=4;this.b_=5};";
michael@0 106 code += "gchild" + i + ".prototype.f4 = function() {this.a_=4;this.b_=5};";
michael@0 107 code += "gchild" + i + ".prototype.f5 = function() {this.a_=4;this.b_=5};";
michael@0 108
michael@0 109 return code;
michael@0 110 }

mercurial