Debian Codegraph @

rhino/testsrc/tests/js1_5/extensions/regress-371636.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-371636.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 371636;
9 var summary = 'Numeric sort performance';
10 var actual = false;
11 var expect = '(tint/tstr < 3)=true';
12
13
14 //-----------------------------------------------------------------------------
15 test();
16 //-----------------------------------------------------------------------------
17
18 function test()
19 {
20 enterFunc ('test');
21 printBugNumber(BUGNUMBER);
22 printStatus (summary);
23
24 function testint(power)
25 {
26 var N = 1 << power;
27 var a = new Array(N);
28 for (var i = 0; i != N; ++i)
29 a[i] = (N-1) & (0x9E3779B9 * i);
30 var now = Date.now;
31 var t = now();
32 a.sort();
33 return now() - t;
34 }
35
36 function teststr(power)
37 {
38 var N = 1 << power;
39 var a = new Array(N);
40 for (var i = 0; i != N; ++i)
41 a[i] = String((N-1) & (0x9E3779B9 * i));
42 var now = Date.now;
43 var t = now();
44 a.sort();
45 return now() - t;
46 }
47
48 var tint = testint(18);
49 var tstr = teststr(18);
50 print('int: ' + tint, 'str: ' + tstr, 'int/str: ' + (tint/tstr).toFixed(2));
51
52 actual = '(tint/tstr < 3)=' + (tint/tstr < 3);
53 reportCompare(expect, actual, summary);
54
55 exitFunc ('test');
56 }