js/src/devtools/gc/tests/clock.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 //Shell version of Clock Benchmark: https://bug548388.bugzilla.mozilla.org/attachment.cgi?id=434576
     3 var t0;
     4 var tl;
     6 function alloc(dt) {
     7     if (dt > 100)
     8         dt = 100;
     9     for (var i = 0; i < dt * 1000; ++i) {
    10         var o = new String("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    11     }
    12 }
    14 function cycle() {
    15     if (!running)
    16         return;
    18     var t1 = new Date;
    19     if (t0 == undefined) t0 = t1;
    21     if (tl != undefined) {
    22         var dt = t1 - tl;
    23         alloc(dt);
    24     }
    26     tl = t1;
    28     if(t1 - t0 > (5 * 1000))
    29         running = false;
    30 }
    32 var running = true;
    33 while(running)
    34     cycle();

mercurial