compute performance baseline in a webworker (#172405)

* compute performance baseline in a webworker

https://github.com/microsoft/vscode/issues/172239

* make build happy, better change overall
This commit is contained in:
Johannes Rieken
2023-01-26 11:44:55 +01:00
committed by GitHub
parent da4e6a6fa2
commit 212bb1a254
2 changed files with 42 additions and 21 deletions

View File

@@ -9,6 +9,13 @@ import { IWorker, IWorkerCallback, IWorkerFactory, logOnceWebWorkerWarning } fro
const ttPolicy = window.trustedTypes?.createPolicy('defaultWorkerFactory', { createScriptURL: value => value });
export function createBlobWorker(blobUrl: string, options?: WorkerOptions): Worker {
if (!blobUrl.startsWith('blob:')) {
throw new URIError('Not a blob-url: ' + blobUrl);
}
return new Worker(ttPolicy ? ttPolicy.createScriptURL(blobUrl) as unknown as string : blobUrl, options);
}
function getWorker(label: string): Worker | Promise<Worker> {
// Option for hosts to overwrite the worker script (used in the standalone editor)
if (globals.MonacoEnvironment) {