js/src/tests/js1_5/Array/regress-101964.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 -- bogus perf test (bug 467263)
     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  * Date: 27 September 2001
     9  *
    10  * SUMMARY: Performance: truncating even very large arrays should be fast!
    11  * See http://bugzilla.mozilla.org/show_bug.cgi?id=101964
    12  *
    13  * Adjust this testcase if necessary. The FAST constant defines
    14  * an upper bound in milliseconds for any truncation to take.
    15  */
    16 //-----------------------------------------------------------------------------
    17 var UBound = 0;
    18 var BUGNUMBER = 101964;
    19 var summary = 'Performance: truncating even very large arrays should be fast!';
    20 var BIG = 10000000;
    21 var LITTLE = 10;
    22 var FAST = 50; // array truncation should be 50 ms or less to pass the test
    23 var MSG_FAST = 'Truncation took less than ' + FAST + ' ms';
    24 var MSG_SLOW = 'Truncation took ';
    25 var MSG_MS = ' ms';
    26 var status = '';
    27 var statusitems = [];
    28 var actual = '';
    29 var actualvalues = [];
    30 var expect= '';
    31 var expectedvalues = [];
    35 status = inSection(1);
    36 var arr = Array(BIG);
    37 var start = new Date();
    38 arr.length = LITTLE;
    39 actual = elapsedTime(start);
    40 expect = FAST;
    41 addThis();
    45 //-----------------------------------------------------------------------------
    46 test();
    47 //-----------------------------------------------------------------------------
    51 function elapsedTime(startTime)
    52 {
    53   return new Date() - startTime;
    54 }
    57 function addThis()
    58 {
    59   statusitems[UBound] = status;
    60   actualvalues[UBound] = isThisFast(actual);
    61   expectedvalues[UBound] = isThisFast(expect);
    62   UBound++;
    63 }
    66 function isThisFast(ms)
    67 {
    68   if (ms <= FAST)
    69     return MSG_FAST;
    70   return MSG_SLOW + ms + MSG_MS;
    71 }
    74 function test()
    75 {
    76   enterFunc ('test');
    77   printBugNumber(BUGNUMBER);
    78   printStatus (summary);
    80   for (var i=0; i<UBound; i++)
    81   {
    82     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
    83   }
    85   exitFunc ('test');
    86 }

mercurial