Skip to content

Commit

Permalink
Track js compilation time (#9794)
Browse files Browse the repository at this point in the history
  • Loading branch information
aznhassan authored Dec 12, 2023
1 parent 508b724 commit aa61926
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pxtrunner/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ namespace pxt.runner {

function initInnerAsync() {
pxt.setAppTarget((window as any).pxtTargetBundle)
pxt.analytics.enable(pxt.Util.userLanguage());
Util.assert(!!pxt.appTarget);

const href = window.location.href;
Expand Down Expand Up @@ -468,7 +469,13 @@ namespace pxt.runner {

export async function fetchSimJsInfo(simOptions: SimulateOptions): Promise<pxtc.BuiltSimJsInfo> {
try {
return await pxt.Cloud.downloadBuiltSimJsInfoAsync(simOptions.id);
const start = Date.now();
const result = await pxt.Cloud.downloadBuiltSimJsInfoAsync(simOptions.id);
pxt.tickEvent("perfMeasurement", {
durationMs: Date.now() - start,
operation: "fetchSimJsInfo",
});
return result;
} catch (e) {
// This exception will happen in the majority of cases, so we don't want to log it unless for debugging.
pxt.debug(e.toString());
Expand All @@ -477,6 +484,7 @@ namespace pxt.runner {
}

export async function buildSimJsInfo(simOptions: SimulateOptions): Promise<pxtc.BuiltSimJsInfo> {
const start = Date.now();
await loadPackageAsync(simOptions.id, simOptions.code, simOptions.dependencies);

let didUpgrade = false;
Expand Down Expand Up @@ -539,6 +547,10 @@ namespace pxt.runner {

const res = pxtc.buildSimJsInfo(compileResult);
res.parts = compileResult.usedParts;
pxt.tickEvent("perfMeasurement", {
durationMs: Date.now() - start,
operation: "buildSimJsInfo",
});
return res;
}

Expand Down

0 comments on commit aa61926

Please sign in to comment.