diff --git a/src/engine/runtime.js b/src/engine/runtime.js index 3ba173718..39be44db8 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -7,6 +7,7 @@ const Blocks = require('./blocks'); const BlockType = require('../extension-support/block-type'); const Sequencer = require('./sequencer'); const Thread = require('./thread'); +const Profiler = require('./profiler'); // Virtual I/O devices. const Clock = require('../io/clock'); @@ -1467,6 +1468,24 @@ class Runtime extends EventEmitter { this._step(); }, 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; + } } /**