|
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/. |
|
6 |
|
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 = []; |
|
32 |
|
33 |
|
34 |
|
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(); |
|
42 |
|
43 |
|
44 |
|
45 //----------------------------------------------------------------------------- |
|
46 test(); |
|
47 //----------------------------------------------------------------------------- |
|
48 |
|
49 |
|
50 |
|
51 function elapsedTime(startTime) |
|
52 { |
|
53 return new Date() - startTime; |
|
54 } |
|
55 |
|
56 |
|
57 function addThis() |
|
58 { |
|
59 statusitems[UBound] = status; |
|
60 actualvalues[UBound] = isThisFast(actual); |
|
61 expectedvalues[UBound] = isThisFast(expect); |
|
62 UBound++; |
|
63 } |
|
64 |
|
65 |
|
66 function isThisFast(ms) |
|
67 { |
|
68 if (ms <= FAST) |
|
69 return MSG_FAST; |
|
70 return MSG_SLOW + ms + MSG_MS; |
|
71 } |
|
72 |
|
73 |
|
74 function test() |
|
75 { |
|
76 enterFunc ('test'); |
|
77 printBugNumber(BUGNUMBER); |
|
78 printStatus (summary); |
|
79 |
|
80 for (var i=0; i<UBound; i++) |
|
81 { |
|
82 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
|
83 } |
|
84 |
|
85 exitFunc ('test'); |
|
86 } |