summaryrefslogtreecommitdiffstats
path: root/toolkit/components/aboutperformance/tests/browser/workers_memory_script.js
blob: 0c0f2e65d773760c51752ec762a733857a52a08f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var big_array = [];
var n = 0;

onmessage = function (e) {
  var sum = 0;
  if (n == 0) {
    for (let i = 0; i < 4 * 1024 * 1024; i++) {
      big_array[i] = i * i;
    }
  } else {
    for (let i = 0; i < 4 * 1024 * 1024; i++) {
      sum += big_array[i];
      big_array[i] += 1;
    }
  }
  self.postMessage(`Iter: ${n}, sum: ${sum}`);
  n++;
};