From 38638ce0dba2b1b08da26bfad870a071fdec2791 Mon Sep 17 00:00:00 2001 From: Hassan Sufi Date: Tue, 5 Dec 2023 16:53:58 -0800 Subject: [PATCH 1/5] Keep track of compilation times --- pxtrunner/runner.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pxtrunner/runner.ts b/pxtrunner/runner.ts index d9f56c031e15..670555370548 100644 --- a/pxtrunner/runner.ts +++ b/pxtrunner/runner.ts @@ -468,7 +468,10 @@ namespace pxt.runner { export async function fetchSimJsInfo(simOptions: SimulateOptions): Promise { try { - return await pxt.Cloud.downloadBuiltSimJsInfoAsync(simOptions.id); + const start = Date.now(); + const result = await pxt.Cloud.downloadBuiltSimJsInfoAsync(simOptions.id); + tickEvent("runner.fetchSimJsInfo", { downloadTime: Date.now() - start }); + 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()); @@ -477,6 +480,7 @@ namespace pxt.runner { } export async function buildSimJsInfo(simOptions: SimulateOptions): Promise { + const start = Date.now(); await loadPackageAsync(simOptions.id, simOptions.code, simOptions.dependencies); let didUpgrade = false; @@ -539,6 +543,7 @@ namespace pxt.runner { const res = pxtc.buildSimJsInfo(compileResult); res.parts = compileResult.usedParts; + tickEvent("runner.buildSimJsInfo", { compileTime: Date.now() - start }); return res; } From f9ce4bec10edfa61abd901b0c85e4ac0a47ee120 Mon Sep 17 00:00:00 2001 From: Hassan Sufi Date: Tue, 5 Dec 2023 21:47:37 -0800 Subject: [PATCH 2/5] Enable telemetry in runner page --- pxtrunner/runner.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pxtrunner/runner.ts b/pxtrunner/runner.ts index 670555370548..d706e6f37f54 100644 --- a/pxtrunner/runner.ts +++ b/pxtrunner/runner.ts @@ -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; @@ -470,7 +471,7 @@ namespace pxt.runner { try { const start = Date.now(); const result = await pxt.Cloud.downloadBuiltSimJsInfoAsync(simOptions.id); - tickEvent("runner.fetchSimJsInfo", { downloadTime: Date.now() - start }); + pxt.tickEvent("runner.fetchSimJsInfo", { duration: Date.now() - start}); return result; } catch (e) { // This exception will happen in the majority of cases, so we don't want to log it unless for debugging. @@ -543,7 +544,7 @@ namespace pxt.runner { const res = pxtc.buildSimJsInfo(compileResult); res.parts = compileResult.usedParts; - tickEvent("runner.buildSimJsInfo", { compileTime: Date.now() - start }); + pxt.tickEvent("runner.buildSimJsInfo", { duration: Date.now() - start}); return res; } From d4fa7e4867ea425c4c2a8d247f702cafe0eec6bf Mon Sep 17 00:00:00 2001 From: Hassan Sufi Date: Wed, 6 Dec 2023 01:44:55 -0800 Subject: [PATCH 3/5] Change duration to durationMs --- pxtrunner/runner.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pxtrunner/runner.ts b/pxtrunner/runner.ts index d706e6f37f54..8a624fae6187 100644 --- a/pxtrunner/runner.ts +++ b/pxtrunner/runner.ts @@ -471,7 +471,7 @@ namespace pxt.runner { try { const start = Date.now(); const result = await pxt.Cloud.downloadBuiltSimJsInfoAsync(simOptions.id); - pxt.tickEvent("runner.fetchSimJsInfo", { duration: Date.now() - start}); + pxt.tickEvent("runner.fetchSimJsInfo", { durationMs: Date.now() - start}); return result; } catch (e) { // This exception will happen in the majority of cases, so we don't want to log it unless for debugging. @@ -544,7 +544,7 @@ namespace pxt.runner { const res = pxtc.buildSimJsInfo(compileResult); res.parts = compileResult.usedParts; - pxt.tickEvent("runner.buildSimJsInfo", { duration: Date.now() - start}); + pxt.tickEvent("runner.buildSimJsInfo", { durationMs: Date.now() - start}); return res; } From a25e584b11637e06701ecb576ad876a0908d2428 Mon Sep 17 00:00:00 2001 From: Hassan Sufi Date: Wed, 6 Dec 2023 02:41:59 -0800 Subject: [PATCH 4/5] Format added lines --- pxtrunner/runner.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pxtrunner/runner.ts b/pxtrunner/runner.ts index 8a624fae6187..efa015fb89d6 100644 --- a/pxtrunner/runner.ts +++ b/pxtrunner/runner.ts @@ -471,7 +471,7 @@ namespace pxt.runner { try { const start = Date.now(); const result = await pxt.Cloud.downloadBuiltSimJsInfoAsync(simOptions.id); - pxt.tickEvent("runner.fetchSimJsInfo", { durationMs: Date.now() - start}); + pxt.tickEvent("runner.fetchSimJsInfo", { durationMs: Date.now() - start }); return result; } catch (e) { // This exception will happen in the majority of cases, so we don't want to log it unless for debugging. @@ -544,7 +544,7 @@ namespace pxt.runner { const res = pxtc.buildSimJsInfo(compileResult); res.parts = compileResult.usedParts; - pxt.tickEvent("runner.buildSimJsInfo", { durationMs: Date.now() - start}); + pxt.tickEvent("runner.buildSimJsInfo", { durationMs: Date.now() - start }); return res; } From b3053c9cfedbd1263ffc4cc23e6db3f1708ee3d7 Mon Sep 17 00:00:00 2001 From: Hassan Sufi Date: Wed, 6 Dec 2023 06:52:26 -0800 Subject: [PATCH 5/5] Use single event with operatin name to track peformance --- pxtrunner/runner.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pxtrunner/runner.ts b/pxtrunner/runner.ts index efa015fb89d6..273c711cd109 100644 --- a/pxtrunner/runner.ts +++ b/pxtrunner/runner.ts @@ -471,7 +471,10 @@ namespace pxt.runner { try { const start = Date.now(); const result = await pxt.Cloud.downloadBuiltSimJsInfoAsync(simOptions.id); - pxt.tickEvent("runner.fetchSimJsInfo", { durationMs: Date.now() - start }); + 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. @@ -544,7 +547,10 @@ namespace pxt.runner { const res = pxtc.buildSimJsInfo(compileResult); res.parts = compileResult.usedParts; - pxt.tickEvent("runner.buildSimJsInfo", { durationMs: Date.now() - start }); + pxt.tickEvent("perfMeasurement", { + durationMs: Date.now() - start, + operation: "buildSimJsInfo", + }); return res; }