mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 15:02:52 -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 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue