Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit fe1f74d

Browse files
jeffbcrossjbdeboer
authored andcommitted
feat(benchmark): add automatic gc before each test
Also included is a script to launch Chrome Canary with the appropriate flag to enable manual garbage collection. Closes #1133
1 parent ea3eb1e commit fe1f74d

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

benchmark/launch_chrome.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
platform=`uname`
4+
if [[ "$platform" == 'Linux' ]]; then
5+
`google-chrome --js-flags="--expose-gc"`
6+
elif [[ "$platform" == 'Darwin' ]]; then
7+
`/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --js-flags="--expose-gc"`
8+
fi

benchmark/web/bp.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ window.addEventListener('DOMContentLoaded', function() {
3535
btn.innerText = "Loop";
3636
var running = false;
3737
btn.addEventListener('click', loopBenchmark);
38-
38+
3939
container.appendChild(btn);
4040

4141
function loopBenchmark() {
@@ -50,10 +50,10 @@ window.addEventListener('DOMContentLoaded', function() {
5050
if (running) {
5151
window.requestAnimationFrame(function() {
5252
if (running) runBenchmarkSteps(loopB);
53-
});
53+
});
5454
}
5555
};
56-
loopB();
56+
loopB();
5757
});
5858
}
5959
}
@@ -68,7 +68,7 @@ window.addEventListener('DOMContentLoaded', function() {
6868
runBenchmarkSteps(function() {
6969
onceBtn.innerText = "Once";
7070
});
71-
});
71+
});
7272
});
7373
});
7474
container.appendChild(onceBtn);
@@ -99,6 +99,9 @@ window.addEventListener('DOMContentLoaded', function() {
9999
// Run all the steps;
100100
var times = {};
101101
window.benchmarkSteps.forEach(function(bs) {
102+
if (typeof window.gc === 'function') {
103+
window.gc();
104+
}
102105
var startTime = numMilliseconds();
103106
bs.fn();
104107
times[bs.name] = numMilliseconds() - startTime;
@@ -109,7 +112,7 @@ window.addEventListener('DOMContentLoaded', function() {
109112
}
110113

111114
var timesPerAction = {};
112-
115+
113116
var NUM_SAMPLES = 10;
114117
function calcStats(times) {
115118
var iH = '';

0 commit comments

Comments
 (0)