js/src/devtools/gc/tests/clock.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 //Shell version of Clock Benchmark: https://bug548388.bugzilla.mozilla.org/attachment.cgi?id=434576
michael@0 2
michael@0 3 var t0;
michael@0 4 var tl;
michael@0 5
michael@0 6 function alloc(dt) {
michael@0 7 if (dt > 100)
michael@0 8 dt = 100;
michael@0 9 for (var i = 0; i < dt * 1000; ++i) {
michael@0 10 var o = new String("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
michael@0 11 }
michael@0 12 }
michael@0 13
michael@0 14 function cycle() {
michael@0 15 if (!running)
michael@0 16 return;
michael@0 17
michael@0 18 var t1 = new Date;
michael@0 19 if (t0 == undefined) t0 = t1;
michael@0 20
michael@0 21 if (tl != undefined) {
michael@0 22 var dt = t1 - tl;
michael@0 23 alloc(dt);
michael@0 24 }
michael@0 25
michael@0 26 tl = t1;
michael@0 27
michael@0 28 if(t1 - t0 > (5 * 1000))
michael@0 29 running = false;
michael@0 30 }
michael@0 31
michael@0 32 var running = true;
michael@0 33 while(running)
michael@0 34 cycle();
michael@0 35

mercurial