js/src/devtools/gc/tests/loops.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 //Measure plain GC.
     3 var t = [];
     4 var N = 500000
     6 for(var i = 0; i < N; i++)
     7     t[i] = {};
     9 gc()
    11 t = [];
    13 gc();
    15 for(var i = 0; i < N; i++)
    16     t[i] = ({});
    18 gc();
    20 t = [];
    22 gc();
    25 for(var i = 0; i < N; i++)
    26     t[i] = "asdf";
    28 gc();
    30 t = [];
    32 gc();
    35 for(var i = 0; i < N; i++)
    36     t[i] = 1.12345;
    38 gc();
    40 t=[];
    42 gc();
    44 for(var i = 0; i < N; i++) {
    45     t[i] = ({});
    46     if (i != 0)
    47         t[i].a = t[i-1];
    48 }
    50 gc();
    52 t = [];
    54 gc();

mercurial