diff --git a/src/virtual-machine.js b/src/virtual-machine.js index 30e809b6d..131c421c2 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -478,6 +478,9 @@ class VirtualMachine extends EventEmitter { // Clear the current runtime this.clear(); + if (typeof performance !== 'undefined') { + performance.mark('scratch-vm-deserialize-start'); + } const runtime = this.runtime; const deserializePromise = function () { const projectVersion = projectJSON.projectVersion; @@ -492,8 +495,14 @@ class VirtualMachine extends EventEmitter { return Promise.reject('Unable to verify Scratch Project version.'); }; return deserializePromise() - .then(({targets, extensions}) => - this.installTargets(targets, extensions, true)); + .then(({targets, extensions}) => { + if (typeof performance !== 'undefined') { + performance.mark('scratch-vm-deserialize-end'); + performance.measure('scratch-vm-deserialize', + 'scratch-vm-deserialize-start', 'scratch-vm-deserialize-end'); + } + return this.installTargets(targets, extensions, true); + }); } /**