Bug 1112278 - Add some more benchmarks to gc-ubench; r=tests
authorTerrence Cole <terrence@mozilla.com>
Fri, 19 Dec 2014 11:00:48 -0800
changeset 233261 6cd496d732f7b8b58e9ba5c7410d50b284865291
parent 233260 e4bee2367e67a3f6676d13327907fc21665b853d
child 233262 afd92b25e239747e029b5677ce1fea2a8be996a7
push id285
push usernalexander@mozilla.com
push dateSun, 21 Dec 2014 23:30:10 +0000
reviewerstests
bugs1112278
milestone37.0a1
Bug 1112278 - Add some more benchmarks to gc-ubench; r=tests
js/src/devtools/gc-ubench/benchmarks/globalArrayArrayLiteral.js
js/src/devtools/gc-ubench/benchmarks/globalArrayLargeArray.js
js/src/devtools/gc-ubench/benchmarks/globalArrayNewObject.js
js/src/devtools/gc-ubench/benchmarks/globalArrayObjectLiteral.js
js/src/devtools/gc-ubench/benchmarks/globalArrayReallocArray.js
js/src/devtools/gc-ubench/index.html
new file mode 100644
--- /dev/null
+++ b/js/src/devtools/gc-ubench/benchmarks/globalArrayArrayLiteral.js
@@ -0,0 +1,16 @@
+window.tests.set('globalArrayArrayLiteral', (function() {
+var garbage = [];
+var garbageIndex = 0;
+return {
+    description: "var foo = [[], ....]",
+    load: (N) => { garbage = new Array(N); },
+    unload: () => { garbage = []; garbageIndex = 0; },
+    makeGarbage: (N) => {
+        for (var i = 0; i < N; i++) {
+            garbage[garbageIndex++] = ['foo', 'bar', 'baz', 'baa'];
+            if (garbageIndex == garbage.length)
+                garbageIndex = 0;
+        }
+    }
+};
+})());
new file mode 100644
--- /dev/null
+++ b/js/src/devtools/gc-ubench/benchmarks/globalArrayLargeArray.js
@@ -0,0 +1,18 @@
+window.tests.set('globalArrayLargeArray', (function() {
+var garbage = [];
+var garbageIndex = 0;
+return {
+    description: "var foo = [[...], ....]",
+    load: (N) => { garbage = new Array(N); },
+    unload: () => { garbage = []; garbageIndex = 0; },
+    makeGarbage: (N) => {
+        var a = new Array(N);
+        for (var i = 0; i < N; i++) {
+            a[i] = N - i;
+        }
+        garbage[garbageIndex++] = a;
+        if (garbageIndex == garbage.length)
+            garbageIndex = 0;
+    }
+};
+})());
--- a/js/src/devtools/gc-ubench/benchmarks/globalArrayNewObject.js
+++ b/js/src/devtools/gc-ubench/benchmarks/globalArrayNewObject.js
@@ -1,13 +1,12 @@
 window.tests.set('globalArrayNewObject', (function() {
 var garbage = [];
 var garbageIndex = 0;
 return {
-    name: 'globalArrayNewObject',
     description: "var foo = [new Object(), ....]",
     load: (N) => { garbage = new Array(N); },
     unload: () => { garbage = []; garbageIndex = 0; },
     makeGarbage: (N) => {
         for (var i = 0; i < N; i++) {
             garbage[garbageIndex++] = new Object();
             if (garbageIndex == garbage.length)
                 garbageIndex = 0;
new file mode 100644
--- /dev/null
+++ b/js/src/devtools/gc-ubench/benchmarks/globalArrayObjectLiteral.js
@@ -0,0 +1,16 @@
+window.tests.set('globalArrayObjectLiteral', (function() {
+var garbage = [];
+var garbageIndex = 0;
+return {
+    description: "var foo = [{}, ....]",
+    load: (N) => { garbage = new Array(N); },
+    unload: () => { garbage = []; garbageIndex = 0; },
+    makeGarbage: (N) => {
+        for (var i = 0; i < N; i++) {
+            garbage[garbageIndex++] = {a: 'foo', b: 'bar', 0: 'foo', 1: 'bar'};
+            if (garbageIndex == garbage.length)
+                garbageIndex = 0;
+        }
+    }
+};
+})());
new file mode 100644
--- /dev/null
+++ b/js/src/devtools/gc-ubench/benchmarks/globalArrayReallocArray.js
@@ -0,0 +1,18 @@
+window.tests.set('globalArrayReallocArray', (function() {
+var garbage = [];
+var garbageIndex = 0;
+return {
+    description: "var foo = [[,,,], ....]",
+    load: (N) => { garbage = new Array(N); },
+    unload: () => { garbage = []; garbageIndex = 0; },
+    makeGarbage: (N) => {
+        var a = [];
+        for (var i = 0; i < N; i++) {
+            a[i] = N - i;
+        }
+        garbage[garbageIndex++] = a;
+        if (garbageIndex == garbage.length)
+            garbageIndex = 0;
+    }
+};
+})());
--- a/js/src/devtools/gc-ubench/index.html
+++ b/js/src/devtools/gc-ubench/index.html
@@ -4,16 +4,20 @@
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 </head>
 <body onload="onload()" onunload="onunload()">
 
 <!-- Include benchmark modules. -->
 <script>var tests = new Map();</script>
 <script src="benchmarks/noAllocation.js"></script>
 <script src="benchmarks/globalArrayNewObject.js"></script>
+<script src="benchmarks/globalArrayArrayLiteral.js"></script>
+<script src="benchmarks/globalArrayLargeArray.js"></script>
+<script src="benchmarks/globalArrayObjectLiteral.js"></script>
+<script src="benchmarks/globalArrayReallocArray.js"></script>
 
 <!-- Harness implementation. -->
 <script>
 // Per-frame time sampling infra. Also GC'd: hopefully will not perturb things too badly.
 var numSamples = 500;
 var delays = new Array(numSamples);
 var sampleIndex = 0;
 var sampleTime = 16; // ms