]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/mozilla/js1_5/Array/regress-101964.js
JavaScriptCore-1218.tar.gz
[apple/javascriptcore.git] / tests / mozilla / js1_5 / Array / regress-101964.js
CommitLineData
b37bf2e1
A
1/*
2* The contents of this file are subject to the Netscape Public
3* License Version 1.1 (the "License"); you may not use this file
4* except in compliance with the License. You may obtain a copy of
5* the License at http://www.mozilla.org/NPL/
6*
7* Software distributed under the License is distributed on an "AS
8* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9* implied. See the License for the specific language governing
10* rights and limitations under the License.
11*
12* The Original Code is mozilla.org code.
13*
14* The Initial Developer of the Original Code is Netscape
15* Communications Corporation. Portions created by Netscape are
16* Copyright (C) 1998 Netscape Communications Corporation.
17* All Rights Reserved.
18*
19* Contributor(s): pschwartau@netscape.com
20* Date: 27 September 2001
21*
22* SUMMARY: Performance: truncating even very large arrays should be fast!
23* See http://bugzilla.mozilla.org/show_bug.cgi?id=101964
24*
25* Adjust this testcase if necessary. The FAST constant defines
26* an upper bound in milliseconds for any truncation to take.
27*/
28//-----------------------------------------------------------------------------
29var UBound = 0;
30var bug = 101964;
31var summary = 'Performance: truncating even very large arrays should be fast!';
32var BIG = 10000000;
33var LITTLE = 10;
34var FAST = 50; // array truncation should be 50 ms or less to pass the test
35var MSG_FAST = 'Truncation took less than ' + FAST + ' ms';
36var MSG_SLOW = 'Truncation took ';
37var MSG_MS = ' ms';
38var status = '';
39var statusitems = [];
40var actual = '';
41var actualvalues = [];
42var expect= '';
43var expectedvalues = [];
44
45
46
47status = inSection(1);
48var arr = Array(BIG);
49var start = new Date();
50arr.length = LITTLE;
51actual = elapsedTime(start);
52expect = FAST;
53addThis();
54
55
56
57//-----------------------------------------------------------------------------
58test();
59//-----------------------------------------------------------------------------
60
61
62
63function elapsedTime(startTime)
64{
65 return new Date() - startTime;
66}
67
68
69function addThis()
70{
71 statusitems[UBound] = status;
72 actualvalues[UBound] = isThisFast(actual);
73 expectedvalues[UBound] = isThisFast(expect);
74 UBound++;
75}
76
77
78function isThisFast(ms)
79{
80 if (ms <= FAST)
81 return MSG_FAST;
82 return MSG_SLOW + ms + MSG_MS;
83}
84
85
86function test()
87{
88 enterFunc ('test');
89 printBugNumber (bug);
90 printStatus (summary);
91
92 for (var i=0; i<UBound; i++)
93 {
94 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
95 }
96
97 exitFunc ('test');
98}