Bug 1280362 - Remove BigO from shell.js, and remove the one (disabled) test that used it. r=arai
authorJeff Walden <jwalden@mit.edu>
Sat, 23 Apr 2016 17:51:16 -0700
changeset 302849 d3ab52f7cf764dc8ebfd6ff957c91dbf6a38b26a
parent 302848 056efc0848c36ed0a73e4fa5182511fbfc08c1b5
child 302850 4e274e923823aca8d389c42c6e148df0cd4d78e9
push id30376
push usercbook@mozilla.com
push dateTue, 28 Jun 2016 14:09:36 +0000
treeherdermozilla-central@e45890951ce7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1280362
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1280362 - Remove BigO from shell.js, and remove the one (disabled) test that used it. r=arai
js/src/tests/js1_5/Regress/regress-416628.js
js/src/tests/shell.js
deleted file mode 100644
--- a/js/src/tests/js1_5/Regress/regress-416628.js
+++ /dev/null
@@ -1,110 +0,0 @@
-// |reftest| random -- BigO
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-//-----------------------------------------------------------------------------
-var BUGNUMBER = 416628;
-var summary = 'O(n^2) blowup due to overlong cx->tempPool arena list';
-var actual = '';
-var expect = '';
-
-//-----------------------------------------------------------------------------
-test();
-//-----------------------------------------------------------------------------
-
-function test()
-{
-  enterFunc ('test');
-  printBugNumber(BUGNUMBER);
-  printStatus (summary);
- 
-  var data = {X:[], Y:[]};
-
-  Function.prototype.inherits = function(parentCtor) {
-    moo_inherits(this, parentCtor);
-  };
-
-  moo_inherits = function(childCtor, parentCtor) {
-    /** @constructor */
-    function tempCtor() {};
-    tempCtor.prototype = parentCtor.prototype;
-    childCtor.superClass_ = parentCtor.prototype;
-    childCtor.prototype = new tempCtor();
-    childCtor.prototype.constructor = childCtor;
-  };
-
-  var jstart =  100;
-  var jstop  = 1000;
-  var jinterval = (jstop - jstart)/9;
-
-  if (true) { 
-    for (var j = jstart; j < jstop; j += jinterval)
-    {
-      data.X.push(j);
-      var code = '';
-      for (var i = 0; i < j; i++)
-      {
-        code += createCode(i);
-      }
-      gc();
-      var start = new Date();
-      eval(code);
-      var stop = new Date();
-      data.Y.push(stop - start);
-    }
-  }
-
-  var order = BigO(data);
-
-  var msg = '';
-  for (var p = 0; p < data.X.length; p++)
-  {
-    msg += '(' + data.X[p] + ', ' + data.Y[p] + '); ';
-  }
-  printStatus(msg);
-  printStatus('Order: ' + order);
-
-  reportCompare(true, order < 2, 'BigO ' + order + ' < 2');
-
-  exitFunc ('test');
-}
-
-function createCode(i)
-{
-  var code = '';
-
-  code += "var str1_" + i + "='This is 1 a test " + i + " string.';";
-  code += "var str2_" + i + "='This is 2 a test " + i + " string.';";
-  code += "var str3_" + i + "='This is 3 a test " + i + " string.';";
-  code += "var str4_" + i + "='This is 4 a test " + i + " string.';";
-  code += "var str5_" + i + "='This is 5 a test " + i + " string.';";
-  code += "var str6_" + i + "='This is 6 a test " + i + " string.';";
-  code += "var str7_" + i + "='This is 7 a test " + i + " string.';";
-  code += "";
-  code += "var base" + i + " = function() {this.a_=4;this.b_=5};";
-  code += "base" + i + ".f1 = function() {this.a_=4;this.b_=5};";
-  code += "base" + i + ".prototype.f2 = function() {this.a_=4;this.b_=5};";
-  code += "base" + i + ".prototype.f3 = function() {this.a_=4;this.b_=5};";
-  code += "base" + i + ".prototype.f4 = function() {this.a_=4;this.b_=5};";
-  code += "base" + i + ".prototype.f5 = function() {this.a_=4;this.b_=5};";
-  code += "";
-  code += "var child" + i + " = function() {this.a_=4;this.b_=5};";
-  code += "child" + i + ".inherits(base" + i + ");";
-  code += "child" + i + ".f1 = function() {this.a_=4;this.b_=5};";
-  code += "child" + i + ".prototype.f2 = function() {this.a_=4;this.b_=5};";
-  code += "child" + i + ".prototype.f3 = function() {this.a_=4;this.b_=5};";
-  code += "child" + i + ".prototype.f4 = function() {this.a_=4;this.b_=5};";
-  code += "child" + i + ".prototype.f5 = function() {this.a_=4;this.b_=5};";
-  code += "";
-  code += "var gchild" + i + " = function() {this.a_=4;this.b_=5};";
-  code += "gchild" + i + ".inherits(child" + i + ");";
-  code += "gchild" + i + ".f1 = function() {this.a_=4;this.b_=5};";
-  code += "gchild" + i + ".prototype.f2 = function() {this.a_=4;this.b_=5};";
-  code += "gchild" + i + ".prototype.f3 = function() {this.a_=4;this.b_=5};";
-  code += "gchild" + i + ".prototype.f4 = function() {this.a_=4;this.b_=5};";
-  code += "gchild" + i + ".prototype.f5 = function() {this.a_=4;this.b_=5};";
-
-  return code;
-}
--- a/js/src/tests/shell.js
+++ b/js/src/tests/shell.js
@@ -588,148 +588,16 @@ function *Permutations(items) {
             items[0] = items[i];
             items[i] = swap;
             for (let e of Permutations(items.slice(1, items.length)))
                 yield [items[0]].concat(e);
         }
     }
 }
 
-/*
-  Calculate the "order" of a set of data points {X: [], Y: []}
-  by computing successive "derivatives" of the data until
-  the data is exhausted or the derivative is linear.
-*/
-function BigO(data)
-{
-  var order = 0;
-  var origLength = data.X.length;
-
-  while (data.X.length > 2)
-  {
-    var lr = new LinearRegression(data);
-    if (lr.b > 1e-6)
-    {
-      // only increase the order if the slope
-      // is "great" enough
-      order++;
-    }
-
-    if (lr.r > 0.98 || lr.Syx < 1 || lr.b < 1e-6)
-    {
-      // terminate if close to a line lr.r
-      // small error lr.Syx
-      // small slope lr.b
-      break;
-    }
-    data = dataDeriv(data);
-  }
-
-  if (2 == origLength - order)
-  {
-    order = Number.POSITIVE_INFINITY;
-  }
-  return order;
-
-  function LinearRegression(data)
-  {
-    /*
-      y = a + bx
-      for data points (Xi, Yi); 0 <= i < n
-
-      b = (n*SUM(XiYi) - SUM(Xi)*SUM(Yi))/(n*SUM(Xi*Xi) - SUM(Xi)*SUM(Xi))
-      a = (SUM(Yi) - b*SUM(Xi))/n
-    */
-    var i;
-
-    if (data.X.length != data.Y.length)
-    {
-      throw 'LinearRegression: data point length mismatch';
-    }
-    if (data.X.length < 3)
-    {
-      throw 'LinearRegression: data point length < 2';
-    }
-    var n = data.X.length;
-    var X = data.X;
-    var Y = data.Y;
-
-    this.Xavg = 0;
-    this.Yavg = 0;
-
-    var SUM_X  = 0;
-    var SUM_XY = 0;
-    var SUM_XX = 0;
-    var SUM_Y  = 0;
-    var SUM_YY = 0;
-
-    for (i = 0; i < n; i++)
-    {
-      SUM_X  += X[i];
-      SUM_XY += X[i]*Y[i];
-      SUM_XX += X[i]*X[i];
-      SUM_Y  += Y[i];
-      SUM_YY += Y[i]*Y[i];
-    }
-
-    this.b = (n * SUM_XY - SUM_X * SUM_Y)/(n * SUM_XX - SUM_X * SUM_X);
-    this.a = (SUM_Y - this.b * SUM_X)/n;
-
-    this.Xavg = SUM_X/n;
-    this.Yavg = SUM_Y/n;
-
-    var SUM_Ydiff2 = 0;
-    var SUM_Xdiff2 = 0;
-    var SUM_XdiffYdiff = 0;
-
-    for (i = 0; i < n; i++)
-    {
-      var Ydiff = Y[i] - this.Yavg;
-      var Xdiff = X[i] - this.Xavg;
-
-      SUM_Ydiff2 += Ydiff * Ydiff;
-      SUM_Xdiff2 += Xdiff * Xdiff;
-      SUM_XdiffYdiff += Xdiff * Ydiff;
-    }
-
-    var Syx2 = (SUM_Ydiff2 - Math.pow(SUM_XdiffYdiff/SUM_Xdiff2, 2))/(n - 2);
-    var r2   = Math.pow((n*SUM_XY - SUM_X * SUM_Y), 2) /
-      ((n*SUM_XX - SUM_X*SUM_X)*(n*SUM_YY-SUM_Y*SUM_Y));
-
-    this.Syx = Math.sqrt(Syx2);
-    this.r = Math.sqrt(r2);
-
-  }
-
-  function dataDeriv(data)
-  {
-    if (data.X.length != data.Y.length)
-    {
-      throw 'length mismatch';
-    }
-    var length = data.X.length;
-
-    if (length < 2)
-    {
-      throw 'length ' + length + ' must be >= 2';
-    }
-    var X = data.X;
-    var Y = data.Y;
-
-    var deriv = {X: [], Y: [] };
-
-    for (var i = 0; i < length - 1; i++)
-    {
-      deriv.X[i] = (X[i] + X[i+1])/2;
-      deriv.Y[i] = (Y[i+1] - Y[i])/(X[i+1] - X[i]);
-    }
-    return deriv;
-  }
-}
-
 function compareSource(expect, actual, summary)
 {
   // compare source
   var expectP = expect.
     replace(/([(){},.:\[\]])/mg, ' $1 ').
     replace(/(\w+)/mg, ' $1 ').
     replace(/<(\/)? (\w+) (\/)?>/mg, '<$1$2$3>').
     replace(/\s+/mg, ' ').