Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 451673;
9 var summary = 'TM: Tracing prime number generation';
10 var actual = '';
11 var expect = '';
14 //-----------------------------------------------------------------------------
15 test();
16 //-----------------------------------------------------------------------------
18 function test()
19 {
20 enterFunc ('test');
21 printBugNumber(BUGNUMBER);
22 printStatus (summary);
24 function doTest(enablejit)
25 {
26 if (enablejit)
27 jit(true);
28 else
29 jit(false);
31 var n = 1000000;
32 var start = new Date();
33 var i=0;
34 var j=0;
35 var numprimes=0;
36 var limit=0;
37 numprimes = 1; // 2 is prime
38 var mceil = Math.floor;
39 var msqrt = Math.sqrt;
40 var isPrime = 1;
42 for (i = 3; i<= n; i+=2)
43 {
44 isPrime=1;
45 limit = mceil(msqrt(i)+1) + 1;
47 for (j = 3; j < limit; j+=2)
48 {
49 if (i % j == 0)
50 {
51 isPrime = 0;
52 break;
53 }
54 }
56 if (isPrime)
57 {
58 numprimes ++;
59 }
60 }
62 var end = new Date();
64 var timetaken = end - start;
65 timetaken = timetaken / 1000;
67 if (enablejit)
68 jit(false);
70 print((enablejit ? ' JIT' : 'Non-JIT') + ": Number of primes up to: " + n + " is " + numprimes + ", counted in " + timetaken + " secs.");
72 return timetaken;
73 }
75 var timenonjit = doTest(false);
76 var timejit = doTest(true);
78 expect = true;
79 actual = timejit < timenonjit;
81 reportCompare(expect, actual, summary);
83 exitFunc ('test');
84 }