Debian Codegraph @

rhino/testsrc/tests/js1_5/Regress/regress-169559.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 var gTestfile = 'regress-169559.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 169559;
9 var summary = 'Global vars should not be more than 2.5 times slower than local';
10 var actual = '';
11 var expect = '';
12
13 printBugNumber(BUGNUMBER);
14 printStatus (summary);
15
16 var starttime;
17 var stoptime;
18 var globaltime = 0;
19 var localtime = 0;
20 var maxratio = 2.5;
21 var ratio;
22
23 var globalvar;
24 var globaltotal = 0;
25
26 // Warm up
27 global();
28 local();
29
30 printStatus("Testing global variables");
31 starttime = new Date();
32 global();
33 stoptime = new Date();
34 globaltime = stoptime - starttime;
35
36 printStatus("Testing local variables");
37 starttime= new Date();
38 local();
39 stoptime = new Date();
40 localtime = stoptime - starttime;
41
42 ratio = globaltime/localtime;
43 printStatus("Ratio of global to local time " + ratio.toFixed(3));
44
45 expect = true;
46 actual = (ratio < maxratio);
47 summary += ', Ratio: ' + ratio + ' ';
48 reportCompare(expect, actual, summary);
49
50 function global()
51 {
52 for (globalvar = 0; globalvar < 100000; globalvar++)
53 {
54 globaltotal += 1;
55 }
56 }
57
58 function local()
59 {
60 var localvar;
61 var localtotal = 0;
62
63 for (localvar = 0; localvar < 100000; localvar++)
64 {
65 localtotal += 1;
66 }
67
68 }