Merge pull request #2903 from cwillisf/performance-mark-deserialize

use performance.mark to measure deserialize time
This commit is contained in:
Christopher Willis-Ford 2021-10-29 07:32:14 -07:00 committed by GitHub
commit d119ca2477
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -478,6 +478,9 @@ class VirtualMachine extends EventEmitter {
// Clear the current runtime // Clear the current runtime
this.clear(); this.clear();
if (typeof performance !== 'undefined') {
performance.mark('scratch-vm-deserialize-start');
}
const runtime = this.runtime; const runtime = this.runtime;
const deserializePromise = function () { const deserializePromise = function () {
const projectVersion = projectJSON.projectVersion; const projectVersion = projectJSON.projectVersion;
@ -492,8 +495,14 @@ class VirtualMachine extends EventEmitter {
return Promise.reject('Unable to verify Scratch Project version.'); return Promise.reject('Unable to verify Scratch Project version.');
}; };
return deserializePromise() return deserializePromise()
.then(({targets, extensions}) => .then(({targets, extensions}) => {
this.installTargets(targets, extensions, true)); 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);
});
} }
/** /**