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

feat(benchmark): add automatic gc before each test #1133

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions benchmark/launch_chrome.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

platform=`uname`
if [[ "$platform" == 'Linux' ]]; then
`google-chrome --js-flags="--expose-gc"`
elif [[ "$platform" == 'Darwin' ]]; then
`/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --js-flags="--expose-gc"`
fi
13 changes: 8 additions & 5 deletions benchmark/web/bp.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ window.addEventListener('DOMContentLoaded', function() {
btn.innerText = "Loop";
var running = false;
btn.addEventListener('click', loopBenchmark);

container.appendChild(btn);

function loopBenchmark() {
Expand All @@ -50,10 +50,10 @@ window.addEventListener('DOMContentLoaded', function() {
if (running) {
window.requestAnimationFrame(function() {
if (running) runBenchmarkSteps(loopB);
});
});
}
};
loopB();
loopB();
});
}
}
Expand All @@ -68,7 +68,7 @@ window.addEventListener('DOMContentLoaded', function() {
runBenchmarkSteps(function() {
onceBtn.innerText = "Once";
});
});
});
});
});
container.appendChild(onceBtn);
Expand Down Expand Up @@ -99,6 +99,9 @@ window.addEventListener('DOMContentLoaded', function() {
// Run all the steps;
var times = {};
window.benchmarkSteps.forEach(function(bs) {
if (typeof window.gc === 'function') {
window.gc();
}
var startTime = numMilliseconds();
bs.fn();
times[bs.name] = numMilliseconds() - startTime;
Expand All @@ -109,7 +112,7 @@ window.addEventListener('DOMContentLoaded', function() {
}

var timesPerAction = {};

var NUM_SAMPLES = 10;
function calcStats(times) {
var iH = '';
Expand Down