js/src/tests/js1_5/Array/regress-101964.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_5/Array/regress-101964.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,86 @@
     1.4 +// |reftest| random -- bogus perf test (bug 467263)
     1.5 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.9 +
    1.10 +/*
    1.11 + * Date: 27 September 2001
    1.12 + *
    1.13 + * SUMMARY: Performance: truncating even very large arrays should be fast!
    1.14 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=101964
    1.15 + *
    1.16 + * Adjust this testcase if necessary. The FAST constant defines
    1.17 + * an upper bound in milliseconds for any truncation to take.
    1.18 + */
    1.19 +//-----------------------------------------------------------------------------
    1.20 +var UBound = 0;
    1.21 +var BUGNUMBER = 101964;
    1.22 +var summary = 'Performance: truncating even very large arrays should be fast!';
    1.23 +var BIG = 10000000;
    1.24 +var LITTLE = 10;
    1.25 +var FAST = 50; // array truncation should be 50 ms or less to pass the test
    1.26 +var MSG_FAST = 'Truncation took less than ' + FAST + ' ms';
    1.27 +var MSG_SLOW = 'Truncation took ';
    1.28 +var MSG_MS = ' ms';
    1.29 +var status = '';
    1.30 +var statusitems = [];
    1.31 +var actual = '';
    1.32 +var actualvalues = [];
    1.33 +var expect= '';
    1.34 +var expectedvalues = [];
    1.35 +
    1.36 +
    1.37 +
    1.38 +status = inSection(1);
    1.39 +var arr = Array(BIG);
    1.40 +var start = new Date();
    1.41 +arr.length = LITTLE;
    1.42 +actual = elapsedTime(start);
    1.43 +expect = FAST;
    1.44 +addThis();
    1.45 +
    1.46 +
    1.47 +
    1.48 +//-----------------------------------------------------------------------------
    1.49 +test();
    1.50 +//-----------------------------------------------------------------------------
    1.51 +
    1.52 +
    1.53 +
    1.54 +function elapsedTime(startTime)
    1.55 +{
    1.56 +  return new Date() - startTime;
    1.57 +}
    1.58 +
    1.59 +
    1.60 +function addThis()
    1.61 +{
    1.62 +  statusitems[UBound] = status;
    1.63 +  actualvalues[UBound] = isThisFast(actual);
    1.64 +  expectedvalues[UBound] = isThisFast(expect);
    1.65 +  UBound++;
    1.66 +}
    1.67 +
    1.68 +
    1.69 +function isThisFast(ms)
    1.70 +{
    1.71 +  if (ms <= FAST)
    1.72 +    return MSG_FAST;
    1.73 +  return MSG_SLOW + ms + MSG_MS;
    1.74 +}
    1.75 +
    1.76 +
    1.77 +function test()
    1.78 +{
    1.79 +  enterFunc ('test');
    1.80 +  printBugNumber(BUGNUMBER);
    1.81 +  printStatus (summary);
    1.82 +
    1.83 +  for (var i=0; i<UBound; i++)
    1.84 +  {
    1.85 +    reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
    1.86 +  }
    1.87 +
    1.88 +  exitFunc ('test');
    1.89 +}

mercurial