mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Add enableProfiling and disableProfiling to Runtime
This commit is contained in:
parent
516d4f6f30
commit
f73dae828e
1 changed files with 19 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue