Add enableProfiling and disableProfiling to Runtime

This commit is contained in:
Michael "Z" Goddard 2017-11-09 17:28:40 -05:00
parent 516d4f6f30
commit f73dae828e
No known key found for this signature in database
GPG key ID: 762CD40DD5349872

View file

@ -7,6 +7,7 @@ const Blocks = require('./blocks');
const BlockType = require('../extension-support/block-type'); const BlockType = require('../extension-support/block-type');
const Sequencer = require('./sequencer'); const Sequencer = require('./sequencer');
const Thread = require('./thread'); const Thread = require('./thread');
const Profiler = require('./profiler');
// Virtual I/O devices. // Virtual I/O devices.
const Clock = require('../io/clock'); const Clock = require('../io/clock');
@ -1467,6 +1468,24 @@ class Runtime extends EventEmitter {
this._step(); this._step();
}, interval); }, interval);
} }
/**
* Turn on profiling.
* @param {Profiler/FrameCallback} onFrame A callback handle passed a
* profiling frame when the profiler reports its collected data.
*/
enableProfiling (onFrame) {
if (Profiler.available()) {
this.profiler = new Profiler(onFrame);
}
}
/**
* Turn off profiling.
*/
disableProfiling () {
this.profiler = null;
}
} }
/** /**