|
1 // |reftest| skip -- bogus perf test (bug 540512) |
|
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 var BUGNUMBER = 451974; |
|
9 var summary = 'TM: loops with anon functions should not be slower with jit enabled'; |
|
10 var actual = ''; |
|
11 var expect = ''; |
|
12 |
|
13 |
|
14 //----------------------------------------------------------------------------- |
|
15 test(); |
|
16 //----------------------------------------------------------------------------- |
|
17 |
|
18 function test() |
|
19 { |
|
20 enterFunc ('test'); |
|
21 printBugNumber(BUGNUMBER); |
|
22 printStatus (summary); |
|
23 |
|
24 var chars = '0123456789abcdef'; |
|
25 var size = 10000; |
|
26 var mult = 1000; |
|
27 var densearray = []; |
|
28 var lsize = size; |
|
29 |
|
30 while (lsize--) |
|
31 { |
|
32 densearray.push(chars); |
|
33 } |
|
34 |
|
35 function loop() |
|
36 { |
|
37 var start = new Date(); |
|
38 |
|
39 for (var a = 0; a < mult; a++) |
|
40 { |
|
41 var f = (function(x){}); |
|
42 for (var i = 0, len = densearray.length; i < len; i++) |
|
43 { |
|
44 f(densearray[i]); |
|
45 } |
|
46 } |
|
47 |
|
48 var stop = new Date(); |
|
49 return stop - start; |
|
50 } |
|
51 |
|
52 jit(false); |
|
53 var timenonjit = loop(); |
|
54 jit(true); |
|
55 var timejit = loop(); |
|
56 jit(false); |
|
57 |
|
58 print('time: nonjit = ' + timenonjit + ', jit = ' + timejit); |
|
59 |
|
60 expect = true; |
|
61 actual = timejit < timenonjit/2; |
|
62 |
|
63 reportCompare(expect, actual, summary); |
|
64 |
|
65 exitFunc ('test'); |
|
66 } |