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.

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

mercurial