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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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 }

mercurial