js/src/tests/js1_8_1/jit/regress-451673.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // |reftest| skip -- bogus perf test (bug 540512)
michael@0 2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 //-----------------------------------------------------------------------------
michael@0 8 var BUGNUMBER = 451673;
michael@0 9 var summary = 'TM: Tracing prime number generation';
michael@0 10 var actual = '';
michael@0 11 var expect = '';
michael@0 12
michael@0 13
michael@0 14 //-----------------------------------------------------------------------------
michael@0 15 test();
michael@0 16 //-----------------------------------------------------------------------------
michael@0 17
michael@0 18 function test()
michael@0 19 {
michael@0 20 enterFunc ('test');
michael@0 21 printBugNumber(BUGNUMBER);
michael@0 22 printStatus (summary);
michael@0 23
michael@0 24 function doTest(enablejit)
michael@0 25 {
michael@0 26 if (enablejit)
michael@0 27 jit(true);
michael@0 28 else
michael@0 29 jit(false);
michael@0 30
michael@0 31 var n = 1000000;
michael@0 32 var start = new Date();
michael@0 33 var i=0;
michael@0 34 var j=0;
michael@0 35 var numprimes=0;
michael@0 36 var limit=0;
michael@0 37 numprimes = 1; // 2 is prime
michael@0 38 var mceil = Math.floor;
michael@0 39 var msqrt = Math.sqrt;
michael@0 40 var isPrime = 1;
michael@0 41
michael@0 42 for (i = 3; i<= n; i+=2)
michael@0 43 {
michael@0 44 isPrime=1;
michael@0 45 limit = mceil(msqrt(i)+1) + 1;
michael@0 46
michael@0 47 for (j = 3; j < limit; j+=2)
michael@0 48 {
michael@0 49 if (i % j == 0)
michael@0 50 {
michael@0 51 isPrime = 0;
michael@0 52 break;
michael@0 53 }
michael@0 54 }
michael@0 55
michael@0 56 if (isPrime)
michael@0 57 {
michael@0 58 numprimes ++;
michael@0 59 }
michael@0 60 }
michael@0 61
michael@0 62 var end = new Date();
michael@0 63
michael@0 64 var timetaken = end - start;
michael@0 65 timetaken = timetaken / 1000;
michael@0 66
michael@0 67 if (enablejit)
michael@0 68 jit(false);
michael@0 69
michael@0 70 print((enablejit ? ' JIT' : 'Non-JIT') + ": Number of primes up to: " + n + " is " + numprimes + ", counted in " + timetaken + " secs.");
michael@0 71
michael@0 72 return timetaken;
michael@0 73 }
michael@0 74
michael@0 75 var timenonjit = doTest(false);
michael@0 76 var timejit = doTest(true);
michael@0 77
michael@0 78 expect = true;
michael@0 79 actual = timejit < timenonjit;
michael@0 80
michael@0 81 reportCompare(expect, actual, summary);
michael@0 82
michael@0 83 exitFunc ('test');
michael@0 84 }

mercurial