aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-09-10 12:54:41 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-09-10 12:54:41 -0700
commit5af206545f63c6e8c76cc09e0a34b4fdae2f417e (patch)
treea22326dcf9740a182be094f04550bfea0f4c6143 /tools
parent07befe65843ff236b8abc3e34203c3dd93528734 (diff)
improve infrastructure in reproduceriter
Diffstat (limited to 'tools')
-rwxr-xr-xtools/reproduceriter.py31
1 files changed, 27 insertions, 4 deletions
diff --git a/tools/reproduceriter.py b/tools/reproduceriter.py
index e61df744..4bbb59ea 100755
--- a/tools/reproduceriter.py
+++ b/tools/reproduceriter.py
@@ -270,6 +270,7 @@ var Recorder = (function() {
}
};
// Date.now, performance.now
+ recorder.dnow = Date.now;
Date.now = function() {
if (recorder.dnows.length > 0) {
return recorder.dnows.pop();
@@ -278,6 +279,7 @@ var Recorder = (function() {
throw 'consuming too many values!';
}
};
+ recorder.pnow = performance.now || performance.webkitNow || performance.mozNow || performance.oNow || performance.msNow || dnow;
performance.now = function() {
if (recorder.pnows.length > 0) {
return recorder.pnows.pop();
@@ -294,14 +296,35 @@ var Recorder = (function() {
recorder.addListener = function(target, which, callback, arg) {
recorder['event' + which] = callback;
};
+ recorder.onFinish = [];
+ // Benchmarking hooks - emscripten specific
+ (function() {
+ var totalTime = 0;
+ var iterations = 0;
+ var maxTime = 0;
+ var curr = 0;
+ Module.preMainLoop = function() {
+ curr = recorder.pnow();
+ }
+ Module.postMainLoop = function() {
+ var time = recorder.pnow() - curr;
+ totalTime += time;
+ iterations++;
+ maxTime = Math.max(maxTime, time);
+ };
+ recorder.onFinish.push(function() {
+ console.log('mean frame: ' + (totalTime / iteratioins) + ' ms');
+ console.log('max frame : ' + maxTime + ' ms');
+ });
+ })();
// Finish
recorder.finish = function() {
- if (recorder.onFinish) {
- recorder.onFinish();
- recorder.onFinish = null;
- }
+ recorder.onFinish.forEach(function(finish) {
+ finish();
+ });
};
}
+ recorder.replaying = replaying;
return recorder;
})();
''' + open(os.path.join(in_dir, first_js)).read()