@nimblesite/lsp-profiler-ui 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/out/src/bind-host.d.ts +3 -0
- package/out/src/bind-host.js +52 -0
- package/out/src/bind-host.js.map +1 -0
- package/out/src/context-keys.d.ts +4 -0
- package/out/src/context-keys.js +54 -0
- package/out/src/context-keys.js.map +1 -0
- package/out/src/dap-evaluate.d.ts +84 -0
- package/out/src/dap-evaluate.js +442 -0
- package/out/src/dap-evaluate.js.map +1 -0
- package/out/src/dap-output.d.ts +50 -0
- package/out/src/dap-output.js +177 -0
- package/out/src/dap-output.js.map +1 -0
- package/out/src/debug/adapter-resolution.d.ts +56 -0
- package/out/src/debug/adapter-resolution.js +112 -0
- package/out/src/debug/adapter-resolution.js.map +1 -0
- package/out/src/debug/dap-messages.d.ts +18 -0
- package/out/src/debug/dap-messages.js +71 -0
- package/out/src/debug/dap-messages.js.map +1 -0
- package/out/src/debug/index.d.ts +7 -0
- package/out/src/debug/index.js +27 -0
- package/out/src/debug/index.js.map +1 -0
- package/out/src/debug/launch-config.d.ts +42 -0
- package/out/src/debug/launch-config.js +73 -0
- package/out/src/debug/launch-config.js.map +1 -0
- package/out/src/debug/launch-lifecycle.d.ts +29 -0
- package/out/src/debug/launch-lifecycle.js +40 -0
- package/out/src/debug/launch-lifecycle.js.map +1 -0
- package/out/src/debug/poll.d.ts +25 -0
- package/out/src/debug/poll.js +70 -0
- package/out/src/debug/poll.js.map +1 -0
- package/out/src/debug/profiling.d.ts +34 -0
- package/out/src/debug/profiling.js +81 -0
- package/out/src/debug/profiling.js.map +1 -0
- package/out/src/debug/testing/assertions.d.ts +27 -0
- package/out/src/debug/testing/assertions.js +111 -0
- package/out/src/debug/testing/assertions.js.map +1 -0
- package/out/src/debug/testing/dap-client.d.ts +86 -0
- package/out/src/debug/testing/dap-client.js +204 -0
- package/out/src/debug/testing/dap-client.js.map +1 -0
- package/out/src/debug/testing/index.d.ts +7 -0
- package/out/src/debug/testing/index.js +31 -0
- package/out/src/debug/testing/index.js.map +1 -0
- package/out/src/debug/testing/vscode-harness.d.ts +44 -0
- package/out/src/debug/testing/vscode-harness.js +81 -0
- package/out/src/debug/testing/vscode-harness.js.map +1 -0
- package/out/src/debug/ui-stubs.d.ts +26 -0
- package/out/src/debug/ui-stubs.js +88 -0
- package/out/src/debug/ui-stubs.js.map +1 -0
- package/out/src/debug-link-setup.d.ts +4 -0
- package/out/src/debug-link-setup.js +19 -0
- package/out/src/debug-link-setup.js.map +1 -0
- package/out/src/debug-link-view.d.ts +4 -0
- package/out/src/debug-link-view.js +49 -0
- package/out/src/debug-link-view.js.map +1 -0
- package/out/src/debug-link.d.ts +6 -0
- package/out/src/debug-link.js +95 -0
- package/out/src/debug-link.js.map +1 -0
- package/out/src/debug-selection.d.ts +14 -0
- package/out/src/debug-selection.js +33 -0
- package/out/src/debug-selection.js.map +1 -0
- package/out/src/debuggee-pause.d.ts +11 -0
- package/out/src/debuggee-pause.js +109 -0
- package/out/src/debuggee-pause.js.map +1 -0
- package/out/src/editor-path-key.d.ts +52 -0
- package/out/src/editor-path-key.js +105 -0
- package/out/src/editor-path-key.js.map +1 -0
- package/out/src/failure.d.ts +5 -0
- package/out/src/failure.js +53 -0
- package/out/src/failure.js.map +1 -0
- package/out/src/file-log-sink.d.ts +20 -0
- package/out/src/file-log-sink.js +74 -0
- package/out/src/file-log-sink.js.map +1 -0
- package/out/src/flame-html.d.ts +8 -0
- package/out/src/flame-html.js +104 -0
- package/out/src/flame-html.js.map +1 -0
- package/out/src/flame-model.d.ts +93 -0
- package/out/src/flame-model.js +242 -0
- package/out/src/flame-model.js.map +1 -0
- package/out/src/flame-script-helpers.d.ts +26 -0
- package/out/src/flame-script-helpers.js +71 -0
- package/out/src/flame-script-helpers.js.map +1 -0
- package/out/src/flame-script.d.ts +1 -0
- package/out/src/flame-script.js +332 -0
- package/out/src/flame-script.js.map +1 -0
- package/out/src/flame-time-order.d.ts +14 -0
- package/out/src/flame-time-order.js +112 -0
- package/out/src/flame-time-order.js.map +1 -0
- package/out/src/flamegraph-artifact.d.ts +9 -0
- package/out/src/flamegraph-artifact.js +45 -0
- package/out/src/flamegraph-artifact.js.map +1 -0
- package/out/src/host.d.ts +31 -0
- package/out/src/host.js +6 -0
- package/out/src/host.js.map +1 -0
- package/out/src/ids.d.ts +27 -0
- package/out/src/ids.js +63 -0
- package/out/src/ids.js.map +1 -0
- package/out/src/index.d.ts +42 -0
- package/out/src/index.js +98 -0
- package/out/src/index.js.map +1 -0
- package/out/src/logger.d.ts +50 -0
- package/out/src/logger.js +86 -0
- package/out/src/logger.js.map +1 -0
- package/out/src/memory-autopilot.d.ts +64 -0
- package/out/src/memory-autopilot.js +306 -0
- package/out/src/memory-autopilot.js.map +1 -0
- package/out/src/memory-capture-ids.d.ts +17 -0
- package/out/src/memory-capture-ids.js +45 -0
- package/out/src/memory-capture-ids.js.map +1 -0
- package/out/src/memory-capture-ingest.d.ts +15 -0
- package/out/src/memory-capture-ingest.js +84 -0
- package/out/src/memory-capture-ingest.js.map +1 -0
- package/out/src/memory-capture-legs.d.ts +4 -0
- package/out/src/memory-capture-legs.js +55 -0
- package/out/src/memory-capture-legs.js.map +1 -0
- package/out/src/memory-capture-present.d.ts +32 -0
- package/out/src/memory-capture-present.js +71 -0
- package/out/src/memory-capture-present.js.map +1 -0
- package/out/src/memory-capture-roundtrip.d.ts +17 -0
- package/out/src/memory-capture-roundtrip.js +75 -0
- package/out/src/memory-capture-roundtrip.js.map +1 -0
- package/out/src/memory-capture-state.d.ts +23 -0
- package/out/src/memory-capture-state.js +89 -0
- package/out/src/memory-capture-state.js.map +1 -0
- package/out/src/memory-capture-types.d.ts +28 -0
- package/out/src/memory-capture-types.js +70 -0
- package/out/src/memory-capture-types.js.map +1 -0
- package/out/src/memory-capture.d.ts +24 -0
- package/out/src/memory-capture.js +51 -0
- package/out/src/memory-capture.js.map +1 -0
- package/out/src/memory-dashboard-html.d.ts +3 -0
- package/out/src/memory-dashboard-html.js +327 -0
- package/out/src/memory-dashboard-html.js.map +1 -0
- package/out/src/memory-dashboard-mapping.d.ts +34 -0
- package/out/src/memory-dashboard-mapping.js +135 -0
- package/out/src/memory-dashboard-mapping.js.map +1 -0
- package/out/src/memory-dashboard.d.ts +82 -0
- package/out/src/memory-dashboard.js +142 -0
- package/out/src/memory-dashboard.js.map +1 -0
- package/out/src/memory-decorations.d.ts +61 -0
- package/out/src/memory-decorations.js +247 -0
- package/out/src/memory-decorations.js.map +1 -0
- package/out/src/memory-finalize.d.ts +25 -0
- package/out/src/memory-finalize.js +207 -0
- package/out/src/memory-finalize.js.map +1 -0
- package/out/src/memory-guidance.d.ts +14 -0
- package/out/src/memory-guidance.js +36 -0
- package/out/src/memory-guidance.js.map +1 -0
- package/out/src/memory-inspect-commands.d.ts +20 -0
- package/out/src/memory-inspect-commands.js +114 -0
- package/out/src/memory-inspect-commands.js.map +1 -0
- package/out/src/memory-launch-direct.d.ts +12 -0
- package/out/src/memory-launch-direct.js +74 -0
- package/out/src/memory-launch-direct.js.map +1 -0
- package/out/src/memory-launch.d.ts +4 -0
- package/out/src/memory-launch.js +92 -0
- package/out/src/memory-launch.js.map +1 -0
- package/out/src/memory-leak-offer.d.ts +18 -0
- package/out/src/memory-leak-offer.js +51 -0
- package/out/src/memory-leak-offer.js.map +1 -0
- package/out/src/memory-profiler.d.ts +27 -0
- package/out/src/memory-profiler.js +71 -0
- package/out/src/memory-profiler.js.map +1 -0
- package/out/src/memory-ref-graph.d.ts +62 -0
- package/out/src/memory-ref-graph.js +248 -0
- package/out/src/memory-ref-graph.js.map +1 -0
- package/out/src/memory-ref-picker.d.ts +21 -0
- package/out/src/memory-ref-picker.js +103 -0
- package/out/src/memory-ref-picker.js.map +1 -0
- package/out/src/memory-registration.d.ts +4 -0
- package/out/src/memory-registration.js +63 -0
- package/out/src/memory-registration.js.map +1 -0
- package/out/src/memory-start-core.d.ts +8 -0
- package/out/src/memory-start-core.js +165 -0
- package/out/src/memory-start-core.js.map +1 -0
- package/out/src/memory-start-stop-commands.d.ts +10 -0
- package/out/src/memory-start-stop-commands.js +75 -0
- package/out/src/memory-start-stop-commands.js.map +1 -0
- package/out/src/memory-start.d.ts +6 -0
- package/out/src/memory-start.js +13 -0
- package/out/src/memory-start.js.map +1 -0
- package/out/src/memory-status.d.ts +24 -0
- package/out/src/memory-status.js +135 -0
- package/out/src/memory-status.js.map +1 -0
- package/out/src/palette-vscode.d.ts +2 -0
- package/out/src/palette-vscode.js +50 -0
- package/out/src/palette-vscode.js.map +1 -0
- package/out/src/palette.d.ts +70 -0
- package/out/src/palette.js +150 -0
- package/out/src/palette.js.map +1 -0
- package/out/src/process-bind-panel.d.ts +11 -0
- package/out/src/process-bind-panel.js +65 -0
- package/out/src/process-bind-panel.js.map +1 -0
- package/out/src/process-commands.d.ts +5 -0
- package/out/src/process-commands.js +112 -0
- package/out/src/process-commands.js.map +1 -0
- package/out/src/process-context-keys.d.ts +11 -0
- package/out/src/process-context-keys.js +48 -0
- package/out/src/process-context-keys.js.map +1 -0
- package/out/src/process-decoration.d.ts +18 -0
- package/out/src/process-decoration.js +76 -0
- package/out/src/process-decoration.js.map +1 -0
- package/out/src/process-explorer-rows.d.ts +59 -0
- package/out/src/process-explorer-rows.js +47 -0
- package/out/src/process-explorer-rows.js.map +1 -0
- package/out/src/process-explorer.d.ts +66 -0
- package/out/src/process-explorer.js +241 -0
- package/out/src/process-explorer.js.map +1 -0
- package/out/src/process-group-item.d.ts +8 -0
- package/out/src/process-group-item.js +55 -0
- package/out/src/process-group-item.js.map +1 -0
- package/out/src/process-launch-item.d.ts +12 -0
- package/out/src/process-launch-item.js +57 -0
- package/out/src/process-launch-item.js.map +1 -0
- package/out/src/process-launch.d.ts +47 -0
- package/out/src/process-launch.js +205 -0
- package/out/src/process-launch.js.map +1 -0
- package/out/src/process-message-item.d.ts +10 -0
- package/out/src/process-message-item.js +53 -0
- package/out/src/process-message-item.js.map +1 -0
- package/out/src/process-poll.d.ts +26 -0
- package/out/src/process-poll.js +125 -0
- package/out/src/process-poll.js.map +1 -0
- package/out/src/process-reactivity.d.ts +55 -0
- package/out/src/process-reactivity.js +188 -0
- package/out/src/process-reactivity.js.map +1 -0
- package/out/src/process-registration.d.ts +11 -0
- package/out/src/process-registration.js +55 -0
- package/out/src/process-registration.js.map +1 -0
- package/out/src/process-tree-item.d.ts +18 -0
- package/out/src/process-tree-item.js +219 -0
- package/out/src/process-tree-item.js.map +1 -0
- package/out/src/processes-state.d.ts +75 -0
- package/out/src/processes-state.js +76 -0
- package/out/src/processes-state.js.map +1 -0
- package/out/src/profile-on-launch.d.ts +4 -0
- package/out/src/profile-on-launch.js +16 -0
- package/out/src/profile-on-launch.js.map +1 -0
- package/out/src/profile-server.d.ts +24 -0
- package/out/src/profile-server.js +170 -0
- package/out/src/profile-server.js.map +1 -0
- package/out/src/profiler-attach.d.ts +19 -0
- package/out/src/profiler-attach.js +129 -0
- package/out/src/profiler-attach.js.map +1 -0
- package/out/src/profiler-commands.d.ts +8 -0
- package/out/src/profiler-commands.js +110 -0
- package/out/src/profiler-commands.js.map +1 -0
- package/out/src/profiler-decorations.d.ts +74 -0
- package/out/src/profiler-decorations.js +237 -0
- package/out/src/profiler-decorations.js.map +1 -0
- package/out/src/profiler-dispose.d.ts +6 -0
- package/out/src/profiler-dispose.js +20 -0
- package/out/src/profiler-dispose.js.map +1 -0
- package/out/src/profiler-flamegraph-html.d.ts +61 -0
- package/out/src/profiler-flamegraph-html.js +366 -0
- package/out/src/profiler-flamegraph-html.js.map +1 -0
- package/out/src/profiler-format.d.ts +10 -0
- package/out/src/profiler-format.js +28 -0
- package/out/src/profiler-format.js.map +1 -0
- package/out/src/profiler-launch-cooperative.d.ts +16 -0
- package/out/src/profiler-launch-cooperative.js +167 -0
- package/out/src/profiler-launch-cooperative.js.map +1 -0
- package/out/src/profiler-launch.d.ts +29 -0
- package/out/src/profiler-launch.js +123 -0
- package/out/src/profiler-launch.js.map +1 -0
- package/out/src/profiler-results.d.ts +22 -0
- package/out/src/profiler-results.js +104 -0
- package/out/src/profiler-results.js.map +1 -0
- package/out/src/profiler-session-core.d.ts +42 -0
- package/out/src/profiler-session-core.js +116 -0
- package/out/src/profiler-session-core.js.map +1 -0
- package/out/src/profiler-state.d.ts +87 -0
- package/out/src/profiler-state.js +83 -0
- package/out/src/profiler-state.js.map +1 -0
- package/out/src/profiler-status.d.ts +38 -0
- package/out/src/profiler-status.js +163 -0
- package/out/src/profiler-status.js.map +1 -0
- package/out/src/profiler-styles.d.ts +21 -0
- package/out/src/profiler-styles.js +160 -0
- package/out/src/profiler-styles.js.map +1 -0
- package/out/src/profiler-webview.d.ts +95 -0
- package/out/src/profiler-webview.js +243 -0
- package/out/src/profiler-webview.js.map +1 -0
- package/out/src/profiler.d.ts +23 -0
- package/out/src/profiler.js +113 -0
- package/out/src/profiler.js.map +1 -0
- package/out/src/progress-ops.d.ts +24 -0
- package/out/src/progress-ops.js +135 -0
- package/out/src/progress-ops.js.map +1 -0
- package/out/src/reactive-refresh.d.ts +24 -0
- package/out/src/reactive-refresh.js +33 -0
- package/out/src/reactive-refresh.js.map +1 -0
- package/out/src/sample-summary.d.ts +39 -0
- package/out/src/sample-summary.js +32 -0
- package/out/src/sample-summary.js.map +1 -0
- package/out/src/sampled-view.d.ts +15 -0
- package/out/src/sampled-view.js +56 -0
- package/out/src/sampled-view.js.map +1 -0
- package/out/src/server-command.d.ts +4 -0
- package/out/src/server-command.js +14 -0
- package/out/src/server-command.js.map +1 -0
- package/out/src/settings.d.ts +1 -0
- package/out/src/settings.js +22 -0
- package/out/src/settings.js.map +1 -0
- package/out/src/store.d.ts +34 -0
- package/out/src/store.js +64 -0
- package/out/src/store.js.map +1 -0
- package/out/src/testing/cpu-capture-assertions.d.ts +8 -0
- package/out/src/testing/cpu-capture-assertions.js +71 -0
- package/out/src/testing/cpu-capture-assertions.js.map +1 -0
- package/out/src/testing/cpu-capture-contract.d.ts +8 -0
- package/out/src/testing/cpu-capture-contract.js +123 -0
- package/out/src/testing/cpu-capture-contract.js.map +1 -0
- package/out/src/testing/webview-contract-helpers.d.ts +24 -0
- package/out/src/testing/webview-contract-helpers.js +125 -0
- package/out/src/testing/webview-contract-helpers.js.map +1 -0
- package/out/src/testing/webview-contract-leak.d.ts +2 -0
- package/out/src/testing/webview-contract-leak.js +80 -0
- package/out/src/testing/webview-contract-leak.js.map +1 -0
- package/out/src/testing/webview-contract-memory.d.ts +5 -0
- package/out/src/testing/webview-contract-memory.js +221 -0
- package/out/src/testing/webview-contract-memory.js.map +1 -0
- package/out/src/testing/webview-contract-palette.d.ts +6 -0
- package/out/src/testing/webview-contract-palette.js +121 -0
- package/out/src/testing/webview-contract-palette.js.map +1 -0
- package/out/src/testing/webview-contract-panel.d.ts +7 -0
- package/out/src/testing/webview-contract-panel.js +100 -0
- package/out/src/testing/webview-contract-panel.js.map +1 -0
- package/out/src/testing/webview-contract-results.d.ts +6 -0
- package/out/src/testing/webview-contract-results.js +136 -0
- package/out/src/testing/webview-contract-results.js.map +1 -0
- package/out/src/testing/webview-contract.d.ts +18 -0
- package/out/src/testing/webview-contract.js +23 -0
- package/out/src/testing/webview-contract.js.map +1 -0
- package/out/src/timeouts.d.ts +21 -0
- package/out/src/timeouts.js +30 -0
- package/out/src/timeouts.js.map +1 -0
- package/out/src/trace-actions.d.ts +33 -0
- package/out/src/trace-actions.js +135 -0
- package/out/src/trace-actions.js.map +1 -0
- package/out/src/unknown-shape.d.ts +58 -0
- package/out/src/unknown-shape.js +110 -0
- package/out/src/unknown-shape.js.map +1 -0
- package/out/src/wire-adapters.d.ts +18 -0
- package/out/src/wire-adapters.js +160 -0
- package/out/src/wire-adapters.js.map +1 -0
- package/out/src/wire-generated.d.ts +760 -0
- package/out/src/wire-generated.js +38 -0
- package/out/src/wire-generated.js.map +1 -0
- package/package.json +53 -4
- package/scripts/contributions.mjs +187 -0
- package/README.md +0 -3
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Markup for the interactive sampled view ([PROF-UI-SAMPLED]) that the shared
|
|
3
|
+
// CPU results panel mounts: the header strip + fiber chips, the Left Heavy /
|
|
4
|
+
// Time Order toolbar, the canvas, the tooltip and the JSON data blob, styled by
|
|
5
|
+
// theme-aware --vscode-* variables. No vscode imports — unit tested as a string.
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.FLAME_CSS = exports.escapeHtml = void 0;
|
|
8
|
+
exports.pathBasename = pathBasename;
|
|
9
|
+
exports.flameBody = flameBody;
|
|
10
|
+
const profiler_styles_1 = require("./profiler-styles");
|
|
11
|
+
const sample_summary_1 = require("./sample-summary");
|
|
12
|
+
var profiler_styles_2 = require("./profiler-styles");
|
|
13
|
+
Object.defineProperty(exports, "escapeHtml", { enumerable: true, get: function () { return profiler_styles_2.escapeHtml; } });
|
|
14
|
+
/** The final path segment (both separators), for compact locations. */
|
|
15
|
+
function pathBasename(filePath) {
|
|
16
|
+
const parts = filePath.split(/[\\/]/u);
|
|
17
|
+
const lastPart = parts.at(-1);
|
|
18
|
+
return lastPart !== undefined && lastPart !== "" ? lastPart : filePath;
|
|
19
|
+
}
|
|
20
|
+
function chipsHtml(summary) {
|
|
21
|
+
// Only fibers that produced samples get chips: the speedscope export (and
|
|
22
|
+
// therefore model.fibers) contains exactly those fibers, in the same row
|
|
23
|
+
// order, so the filtered index is what setFiber() needs. Including
|
|
24
|
+
// zero-sample rows would shift every later chip onto the wrong fiber.
|
|
25
|
+
return summary.fibers
|
|
26
|
+
.filter((fiber) => fiber.samples > 0)
|
|
27
|
+
.map((fiber, i) => `<button class="chip" data-fiber="${String(i)}">${(0, profiler_styles_1.escapeHtml)(fiber.label)} · ` +
|
|
28
|
+
`${summary.schedulingKnown === false ? `${String(fiber.samples)} samples` : `${String((0, sample_summary_1.onCpuPct)(fiber))}% on-CPU`}</button>`)
|
|
29
|
+
.join("");
|
|
30
|
+
}
|
|
31
|
+
function fiberOptionsHtml(model) {
|
|
32
|
+
return model.fibers
|
|
33
|
+
.map((fiber, i) => `<option value="${String(i)}">${(0, profiler_styles_1.escapeHtml)(fiber.name)}</option>`)
|
|
34
|
+
.join("");
|
|
35
|
+
}
|
|
36
|
+
// The webview stylesheet: VS Code theme tokens only — no external fonts.
|
|
37
|
+
exports.FLAME_CSS = `
|
|
38
|
+
:root { color-scheme: light dark; }
|
|
39
|
+
* { box-sizing: border-box; }
|
|
40
|
+
body {
|
|
41
|
+
margin: 0; padding: 10px 14px; font-size: 12px;
|
|
42
|
+
font-family: var(--vscode-font-family, sans-serif);
|
|
43
|
+
color: var(--vscode-foreground); background: var(--vscode-editor-background);
|
|
44
|
+
}
|
|
45
|
+
.header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
|
|
46
|
+
.stats { color: var(--vscode-descriptionForeground); }
|
|
47
|
+
.chip {
|
|
48
|
+
border: 1px solid var(--vscode-panel-border, #5558); border-radius: 10px;
|
|
49
|
+
background: var(--vscode-editorWidget-background); color: var(--vscode-foreground);
|
|
50
|
+
padding: 1px 9px; cursor: pointer; font-size: 11px; font-family: inherit;
|
|
51
|
+
}
|
|
52
|
+
.chip.active { border-color: var(--vscode-focusBorder, #3794ff); }
|
|
53
|
+
.toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
|
|
54
|
+
.toggle {
|
|
55
|
+
border: 1px solid transparent; border-radius: 3px; padding: 2px 10px; cursor: pointer;
|
|
56
|
+
background: var(--vscode-button-secondaryBackground, #3a3d41);
|
|
57
|
+
color: var(--vscode-button-secondaryForeground, #ccc); font-family: inherit; font-size: 12px;
|
|
58
|
+
}
|
|
59
|
+
.toggle.active {
|
|
60
|
+
background: var(--vscode-button-background, #0e639c);
|
|
61
|
+
color: var(--vscode-button-foreground, #fff);
|
|
62
|
+
}
|
|
63
|
+
#fiber-select {
|
|
64
|
+
background: var(--vscode-dropdown-background); color: var(--vscode-dropdown-foreground);
|
|
65
|
+
border: 1px solid var(--vscode-dropdown-border, transparent); padding: 2px 4px; font-family: inherit;
|
|
66
|
+
}
|
|
67
|
+
#search {
|
|
68
|
+
flex: 0 1 240px; padding: 2px 6px; font-family: inherit;
|
|
69
|
+
background: var(--vscode-input-background); color: var(--vscode-input-foreground);
|
|
70
|
+
border: 1px solid var(--vscode-input-border, transparent);
|
|
71
|
+
}
|
|
72
|
+
#flame-wrap { position: relative; border: 1px solid var(--vscode-panel-border, #5554); }
|
|
73
|
+
#flame { display: block; max-width: 100%; }
|
|
74
|
+
#tooltip {
|
|
75
|
+
position: fixed; display: none; z-index: 10; pointer-events: none; max-width: 480px;
|
|
76
|
+
padding: 6px 9px; font-size: 11px; border-radius: 3px;
|
|
77
|
+
background: var(--vscode-editorHoverWidget-background, #252526);
|
|
78
|
+
color: var(--vscode-editorHoverWidget-foreground, #ccc);
|
|
79
|
+
border: 1px solid var(--vscode-editorHoverWidget-border, #454545);
|
|
80
|
+
}
|
|
81
|
+
.tt-name { font-weight: 600; }
|
|
82
|
+
.tt-loc, .tt-nums { color: var(--vscode-descriptionForeground); }
|
|
83
|
+
`;
|
|
84
|
+
function embedJson(model, summary) {
|
|
85
|
+
// <-escape so "</script>" inside frame names can never close the blob.
|
|
86
|
+
return JSON.stringify({ model, summary }).replaceAll("<", String.raw `\u003c`);
|
|
87
|
+
}
|
|
88
|
+
/** The interactive sampled view, mounted in the shared CPU results panel. */
|
|
89
|
+
function flameBody(model, summary) {
|
|
90
|
+
return `<div class="header"><span class="stats">${(0, profiler_styles_1.escapeHtml)((0, sample_summary_1.formatSummaryHeader)(summary))}</span>${chipsHtml(summary)}</div>
|
|
91
|
+
<div class="toolbar">
|
|
92
|
+
<button id="btn-left" class="toggle active">Left Heavy</button>
|
|
93
|
+
<button id="btn-time" class="toggle">Time Order</button>
|
|
94
|
+
<select id="fiber-select">${fiberOptionsHtml(model)}</select>
|
|
95
|
+
<input id="search" type="text" placeholder="Search functions (Esc clears)">
|
|
96
|
+
<span id="match-label" class="stats"></span>
|
|
97
|
+
<span id="hidden-label" class="stats"></span>
|
|
98
|
+
<button id="btn-reset" class="toggle">Reset zoom (0)</button>
|
|
99
|
+
</div>
|
|
100
|
+
<div id="flame-wrap"><canvas id="flame"></canvas></div>
|
|
101
|
+
<div id="tooltip"></div>
|
|
102
|
+
<script type="application/json" id="flame-data">${embedJson(model, summary)}</script>`;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=flame-html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flame-html.js","sourceRoot":"","sources":["../../src/flame-html.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,6EAA6E;AAC7E,gFAAgF;AAChF,iFAAiF;;;;;AAGjF,uDAA+C;AAE/C,qDAAiE;AAEjE,qDAA+C;AAAtC,6GAAA,UAAU,OAAA;AAEnB,uEAAuE;AACvE,sBAA6B,QAAgB;IAC3C,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,OAAO,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;AACzE,CAAC;AAED,SAAS,SAAS,CAAC,OAAuB;IACxC,0EAA0E;IAC1E,yEAAyE;IACzE,mEAAmE;IACnE,sEAAsE;IACtE,OAAO,OAAO,CAAC,MAAM;SAClB,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;SACpC,GAAG,CACF,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CACX,oCAAoC,MAAM,CAAC,CAAC,CAAC,KAAK,IAAA,4BAAU,EAAC,KAAK,CAAC,KAAK,CAAC,KAAK;QAC9E,G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Rank } from "./palette";
|
|
4
|
+
export { searchMatches } from "./flame-script-helpers";
|
|
5
|
+
export interface SpeedscopeFrame {
|
|
6
|
+
name: string;
|
|
7
|
+
file?: string;
|
|
8
|
+
line?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface SpeedscopeProfile {
|
|
11
|
+
type: string;
|
|
12
|
+
name: string;
|
|
13
|
+
unit: string;
|
|
14
|
+
startValue: number;
|
|
15
|
+
endValue: number;
|
|
16
|
+
/** Stacks as ROOT-FIRST frame-index arrays, one per sample. */
|
|
17
|
+
samples: number[][];
|
|
18
|
+
/** Weight of each sample, in `unit` (seconds for Osprey exports). */
|
|
19
|
+
weights: number[];
|
|
20
|
+
}
|
|
21
|
+
export interface SpeedscopeFile {
|
|
22
|
+
shared: {
|
|
23
|
+
frames: SpeedscopeFrame[];
|
|
24
|
+
};
|
|
25
|
+
profiles: SpeedscopeProfile[];
|
|
26
|
+
}
|
|
27
|
+
export type Result<Value> = {
|
|
28
|
+
ok: true;
|
|
29
|
+
value: Value;
|
|
30
|
+
} | {
|
|
31
|
+
ok: false;
|
|
32
|
+
error: string;
|
|
33
|
+
};
|
|
34
|
+
/** One renderable slab. x0/x1 are in [0,1] config space; weights in seconds. */
|
|
35
|
+
export interface RenderRect {
|
|
36
|
+
x0: number;
|
|
37
|
+
x1: number;
|
|
38
|
+
depth: number;
|
|
39
|
+
frameIdx: number;
|
|
40
|
+
selfWeight: number;
|
|
41
|
+
totalWeight: number;
|
|
42
|
+
}
|
|
43
|
+
/** Per-frame aggregates for one fiber, indexed by frameIdx. */
|
|
44
|
+
export interface FrameStats {
|
|
45
|
+
self: number[];
|
|
46
|
+
total: number[];
|
|
47
|
+
count: number[];
|
|
48
|
+
}
|
|
49
|
+
export interface FiberFlame {
|
|
50
|
+
name: string;
|
|
51
|
+
totalWeight: number;
|
|
52
|
+
sampleCount: number;
|
|
53
|
+
maxDepthLeft: number;
|
|
54
|
+
maxDepthTime: number;
|
|
55
|
+
leftHeavy: RenderRect[];
|
|
56
|
+
timeOrder: RenderRect[];
|
|
57
|
+
/** Narrow slabs each layout's budget left undrawn (see flame-time-order.ts). */
|
|
58
|
+
leftHeavyHidden: number;
|
|
59
|
+
timeOrderHidden: number;
|
|
60
|
+
stats: FrameStats;
|
|
61
|
+
}
|
|
62
|
+
export interface FrameMeta {
|
|
63
|
+
source?: boolean;
|
|
64
|
+
name: string;
|
|
65
|
+
file: string;
|
|
66
|
+
line: number;
|
|
67
|
+
color: string;
|
|
68
|
+
}
|
|
69
|
+
export interface FlameModel {
|
|
70
|
+
frames: FrameMeta[];
|
|
71
|
+
fibers: FiberFlame[];
|
|
72
|
+
}
|
|
73
|
+
/** JSON.parse into a Result — shared by both profiler artifact parsers. */
|
|
74
|
+
export declare function parseJsonResult(text: string, what: string): Result<unknown>;
|
|
75
|
+
/** Parse + validate a speedscope JSON document. Never throws. */
|
|
76
|
+
export declare function parseSpeedscope(text: string): Result<SpeedscopeFile>;
|
|
77
|
+
/** Merge samples into the aggregated left-heavy layout (heaviest first). */
|
|
78
|
+
export declare function leftHeavyRects(profile: SpeedscopeProfile): RenderRect[];
|
|
79
|
+
export declare function frameStats(profile: SpeedscopeProfile, frameCount: number): FrameStats;
|
|
80
|
+
/** Triangle wave in [0,1] with period 2 — speedscope's color mixer. */
|
|
81
|
+
export declare const triangle: (value: number) => number;
|
|
82
|
+
/** One frame's place in the color ramp: its file and its rank among `frameCount` frames. */
|
|
83
|
+
export interface RankedFrame {
|
|
84
|
+
readonly file: string;
|
|
85
|
+
readonly rank: number;
|
|
86
|
+
readonly frameCount: number;
|
|
87
|
+
}
|
|
88
|
+
/** Deterministic speedscope-style color for the frame ranked `rank` of `frameCount`. */
|
|
89
|
+
export declare function colorForRank({ file, rank, frameCount }: RankedFrame, isSource?: typeof hasSourceFile): string;
|
|
90
|
+
/** Stable per-frame colors: frames ranked by (file+name), ramped over hue. */
|
|
91
|
+
export declare function frameColors(frames: SpeedscopeFrame[], isSource?: typeof hasSourceFile): string[];
|
|
92
|
+
/** The complete serializable model for one speedscope document. */
|
|
93
|
+
export declare function buildFlameModel(doc: SpeedscopeFile, isSource?: typeof hasSourceFile): FlameModel;
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Shared sampled flame-graph model. Implements [PROF-UI-SAMPLED].
|
|
3
|
+
// Parses the speedscope "sampled" export produced by a runtime
|
|
4
|
+
// and precomputes everything the canvas renderer needs: a LEFT-HEAVY layout
|
|
5
|
+
// (samples merged into an aggregated tree, heaviest children first) and a
|
|
6
|
+
// TIME-ORDER layout (a flame chart where adjacent identical stacks fuse into
|
|
7
|
+
// continuous slabs), plus per-frame self/total weights, deterministic frame
|
|
8
|
+
// colors, and substring search. No vscode imports — everything here is unit
|
|
9
|
+
// testable and JSON-serializable for embedding in the webview.
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.triangle = exports.searchMatches = exports.byFrameKeyThenIndex = exports.timeOrderRects = void 0;
|
|
12
|
+
exports.parseJsonResult = parseJsonResult;
|
|
13
|
+
exports.parseSpeedscope = parseSpeedscope;
|
|
14
|
+
exports.leftHeavyRects = leftHeavyRects;
|
|
15
|
+
exports.frameStats = frameStats;
|
|
16
|
+
exports.colorForRank = colorForRank;
|
|
17
|
+
exports.frameColors = frameColors;
|
|
18
|
+
exports.buildFlameModel = buildFlameModel;
|
|
19
|
+
const flame_time_order_1 = require("./flame-time-order");
|
|
20
|
+
const unknown_shape_1 = require("./unknown-shape");
|
|
21
|
+
const palette_1 = require("./palette");
|
|
22
|
+
var flame_time_order_2 = require("./flame-time-order");
|
|
23
|
+
Object.defineProperty(exports, "timeOrderRects", { enumerable: true, get: function () { return flame_time_order_2.timeOrderRects; } });
|
|
24
|
+
var palette_2 = require("./palette");
|
|
25
|
+
Object.defineProperty(exports, "byFrameKeyThenIndex", { enumerable: true, get: function () { return palette_2.byFrameKeyThenIndex; } });
|
|
26
|
+
var flame_script_helpers_1 = require("./flame-script-helpers");
|
|
27
|
+
Object.defineProperty(exports, "searchMatches", { enumerable: true, get: function () { return flame_script_helpers_1.searchMatches; } });
|
|
28
|
+
// --- parsing -----------------------------------------------------------------
|
|
29
|
+
function isFrame(value) {
|
|
30
|
+
return (0, unknown_shape_1.isRecord)(value) && typeof value.name === "string";
|
|
31
|
+
}
|
|
32
|
+
const isWeight = (weight) => typeof weight === "number" && Number.isFinite(weight) && weight >= 0;
|
|
33
|
+
const isStack = (stack, frameCount) => Array.isArray(stack) && stack.every((frame) => Number.isInteger(frame) && frame >= 0 && frame < frameCount);
|
|
34
|
+
/** What is wrong with one profile, if anything. */
|
|
35
|
+
function profileError(raw, frameCount) {
|
|
36
|
+
if (!(0, unknown_shape_1.isRecord)(raw)) {
|
|
37
|
+
return "speedscope file has a profile that is not an object";
|
|
38
|
+
}
|
|
39
|
+
const name = String(raw.name);
|
|
40
|
+
return profileShapeError(raw, name, frameCount);
|
|
41
|
+
}
|
|
42
|
+
/** What is wrong with the shape of one parsed profile. */
|
|
43
|
+
function profileShapeError(raw, name, frameCount) {
|
|
44
|
+
const { type, samples, weights } = raw;
|
|
45
|
+
if (type !== "sampled") {
|
|
46
|
+
return `profile "${name}" has unsupported type "${String(type)}"`;
|
|
47
|
+
}
|
|
48
|
+
if (!Array.isArray(samples) || !Array.isArray(weights)) {
|
|
49
|
+
return `profile "${name}" is missing samples/weights`;
|
|
50
|
+
}
|
|
51
|
+
if (samples.length !== weights.length) {
|
|
52
|
+
return `profile "${name}" has ${String(samples.length)} samples but ${String(weights.length)} weights`;
|
|
53
|
+
}
|
|
54
|
+
if (!weights.every((weight) => isWeight(weight))) {
|
|
55
|
+
return `profile "${name}" has a weight that is not a non-negative number`;
|
|
56
|
+
}
|
|
57
|
+
return samples.every((stack) => isStack(stack, frameCount)) ? undefined : `profile "${name}" references a frame outside shared.frames`;
|
|
58
|
+
}
|
|
59
|
+
/** What is wrong with a parsed speedscope document, if anything. */
|
|
60
|
+
function speedscopeError(doc) {
|
|
61
|
+
const shared = (0, unknown_shape_1.isRecord)(doc) ? doc.shared : undefined;
|
|
62
|
+
const frames = (0, unknown_shape_1.isRecord)(shared) ? shared.frames : undefined;
|
|
63
|
+
if (!Array.isArray(frames) || !frames.every((frame) => isFrame(frame))) {
|
|
64
|
+
return "speedscope file is missing shared.frames";
|
|
65
|
+
}
|
|
66
|
+
const profiles = (0, unknown_shape_1.isRecord)(doc) ? doc.profiles : undefined;
|
|
67
|
+
if (!Array.isArray(profiles) || profiles.length === 0) {
|
|
68
|
+
return "speedscope file has no profiles";
|
|
69
|
+
}
|
|
70
|
+
return profiles.map((profile) => profileError(profile, frames.length)).find((error) => error !== undefined);
|
|
71
|
+
}
|
|
72
|
+
/** The document's outline; `speedscopeError` has checked everything inside it. */
|
|
73
|
+
function isSpeedscopeFile(doc) {
|
|
74
|
+
return (0, unknown_shape_1.isRecord)(doc) && (0, unknown_shape_1.isRecord)(doc.shared) && Array.isArray(doc.profiles);
|
|
75
|
+
}
|
|
76
|
+
/** JSON.parse into a Result — shared by both profiler artifact parsers. */
|
|
77
|
+
function parseJsonResult(text, what) {
|
|
78
|
+
try {
|
|
79
|
+
return { ok: true, value: JSON.parse(text) };
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
return { ok: false, error: `${what} is not valid JSON: ${String(error)}` };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** Parse + validate a speedscope JSON document. Never throws. */
|
|
86
|
+
function parseSpeedscope(text) {
|
|
87
|
+
const raw = parseJsonResult(text, "speedscope file");
|
|
88
|
+
if (!raw.ok) {
|
|
89
|
+
return raw;
|
|
90
|
+
}
|
|
91
|
+
const error = speedscopeError(raw.value);
|
|
92
|
+
return error === undefined && isSpeedscopeFile(raw.value)
|
|
93
|
+
? { ok: true, value: raw.value }
|
|
94
|
+
: { ok: false, error: error ?? "speedscope file is missing shared.frames" };
|
|
95
|
+
}
|
|
96
|
+
function childOf(children, frameIdx) {
|
|
97
|
+
const existing = children.get(frameIdx);
|
|
98
|
+
if (existing !== undefined) {
|
|
99
|
+
return existing;
|
|
100
|
+
}
|
|
101
|
+
const node = { frameIdx, total: 0, self: 0, children: new Map() };
|
|
102
|
+
children.set(frameIdx, node);
|
|
103
|
+
return node;
|
|
104
|
+
}
|
|
105
|
+
function insertStack(root, stack, weight) {
|
|
106
|
+
let children = root;
|
|
107
|
+
let node = undefined;
|
|
108
|
+
for (const frameIdx of stack) {
|
|
109
|
+
node = childOf(children, frameIdx);
|
|
110
|
+
node.total += weight;
|
|
111
|
+
({ children } = node);
|
|
112
|
+
}
|
|
113
|
+
if (node !== undefined) {
|
|
114
|
+
node.self += weight;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function sortedByWeight(children) {
|
|
118
|
+
return [...children.values()].toSorted((left, right) => right.total - left.total || left.frameIdx - right.frameIdx);
|
|
119
|
+
}
|
|
120
|
+
function emitAggNodes(nodes, state) {
|
|
121
|
+
for (const node of nodes) {
|
|
122
|
+
state.out.push({
|
|
123
|
+
x0: state.x * state.scale,
|
|
124
|
+
x1: (state.x + node.total) * state.scale,
|
|
125
|
+
depth: state.depth,
|
|
126
|
+
frameIdx: node.frameIdx,
|
|
127
|
+
selfWeight: node.self,
|
|
128
|
+
totalWeight: node.total,
|
|
129
|
+
});
|
|
130
|
+
emitAggNodes(sortedByWeight(node.children), {
|
|
131
|
+
x: state.x,
|
|
132
|
+
depth: state.depth + 1,
|
|
133
|
+
scale: state.scale,
|
|
134
|
+
out: state.out,
|
|
135
|
+
});
|
|
136
|
+
state.x += node.total;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/** Merge samples into the aggregated left-heavy layout (heaviest first). */
|
|
140
|
+
function leftHeavyRects(profile) {
|
|
141
|
+
const total = profile.weights.reduce((sum, weight) => sum + weight, 0);
|
|
142
|
+
if (total <= 0) {
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
const root = new Map();
|
|
146
|
+
for (const [index, stack] of profile.samples.entries()) {
|
|
147
|
+
insertStack(root, stack, profile.weights[index]);
|
|
148
|
+
}
|
|
149
|
+
const out = [];
|
|
150
|
+
emitAggNodes(sortedByWeight(root), { x: 0, depth: 0, scale: 1 / total, out });
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
// --- per-frame aggregates ---------------------------------------------------------
|
|
154
|
+
/** Self/total weight and sample count per frameIdx (recursion deduplicated). */
|
|
155
|
+
function zeros(count) {
|
|
156
|
+
return Array.from({ length: count }, () => 0);
|
|
157
|
+
}
|
|
158
|
+
function frameStats(profile, frameCount) {
|
|
159
|
+
const stats = { self: zeros(frameCount), total: zeros(frameCount), count: zeros(frameCount) };
|
|
160
|
+
for (const [index, stack] of profile.samples.entries()) {
|
|
161
|
+
const weight = profile.weights[index];
|
|
162
|
+
for (const frameIdx of new Set(stack)) {
|
|
163
|
+
stats.total[frameIdx] += weight;
|
|
164
|
+
stats.count[frameIdx] += 1;
|
|
165
|
+
}
|
|
166
|
+
const leaf = stack.at(-1);
|
|
167
|
+
if (leaf !== undefined) {
|
|
168
|
+
stats.self[leaf] += weight;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return stats;
|
|
172
|
+
}
|
|
173
|
+
// --- colors -----------------------------------------------------------------------
|
|
174
|
+
const COLOR_CHANNEL_MAX = 255;
|
|
175
|
+
const TRIANGLE_HALF = 0.5;
|
|
176
|
+
const RUNTIME_HUE = 215;
|
|
177
|
+
const RUNTIME_HUE_MIX_STEPS = 30;
|
|
178
|
+
const RUNTIME_LIGHTNESS_BASE = 58;
|
|
179
|
+
const RUNTIME_LIGHTNESS_RANGE = 12;
|
|
180
|
+
const SOURCE_HUE_RANGE = 324;
|
|
181
|
+
const SOURCE_SATURATION_BASE = 25;
|
|
182
|
+
const SOURCE_SATURATION_RANGE = 20;
|
|
183
|
+
const SOURCE_LIGHTNESS_BASE = 65;
|
|
184
|
+
const SOURCE_LIGHTNESS_RANGE = 15;
|
|
185
|
+
/** Triangle wave in [0,1] with period 2 — speedscope's color mixer. */
|
|
186
|
+
const triangle = (value) => 2 * Math.abs(value / 2 - Math.floor(value / 2 + TRIANGLE_HALF));
|
|
187
|
+
exports.triangle = triangle;
|
|
188
|
+
/** Deterministic speedscope-style color for the frame ranked `rank` of `frameCount`. */
|
|
189
|
+
function colorForRank({ file, rank, frameCount }, isSource = palette_1.hasSourceFile) {
|
|
190
|
+
const bucket = Math.floor((COLOR_CHANNEL_MAX * rank) / Math.max(frameCount, 1));
|
|
191
|
+
const hue = bucket / COLOR_CHANNEL_MAX;
|
|
192
|
+
const mix = (0, exports.triangle)(RUNTIME_HUE_MIX_STEPS * hue);
|
|
193
|
+
if (!isSource(file)) {
|
|
194
|
+
return `hsl(${String(RUNTIME_HUE)}, 12%, ${(RUNTIME_LIGHTNESS_BASE - RUNTIME_LIGHTNESS_RANGE * mix).toFixed(1)}%)`;
|
|
195
|
+
}
|
|
196
|
+
return `hsl(${(SOURCE_HUE_RANGE * hue).toFixed(1)}, ${(SOURCE_SATURATION_BASE + SOURCE_SATURATION_RANGE * mix).toFixed(1)}%, ${(SOURCE_LIGHTNESS_BASE - SOURCE_LIGHTNESS_RANGE * mix).toFixed(1)}%)`;
|
|
197
|
+
}
|
|
198
|
+
/** Stable per-frame colors: frames ranked by (file+name), ramped over hue. */
|
|
199
|
+
function frameColors(frames, isSource = palette_1.hasSourceFile) {
|
|
200
|
+
const ranks = (0, palette_1.frameRanks)(frames);
|
|
201
|
+
return frames.map((frame, i) => colorForRank({ file: frame.file ?? "", rank: ranks[i] ?? i, frameCount: frames.length }, isSource));
|
|
202
|
+
}
|
|
203
|
+
// --- assembly ------------------------------------------------------------------------
|
|
204
|
+
function maxDepth(rects) {
|
|
205
|
+
let deepest = 0;
|
|
206
|
+
for (const rect of rects) {
|
|
207
|
+
deepest = Math.max(deepest, rect.depth + 1);
|
|
208
|
+
}
|
|
209
|
+
return deepest;
|
|
210
|
+
}
|
|
211
|
+
function buildFiber(profile, frameCount) {
|
|
212
|
+
const totalWeight = profile.weights.reduce((sum, weight) => sum + weight, 0);
|
|
213
|
+
const leftHeavy = (0, flame_time_order_1.boundedRects)(leftHeavyRects(profile), totalWeight);
|
|
214
|
+
const timeOrder = (0, flame_time_order_1.boundedTimeOrder)(profile);
|
|
215
|
+
return {
|
|
216
|
+
name: profile.name,
|
|
217
|
+
totalWeight,
|
|
218
|
+
sampleCount: profile.samples.length,
|
|
219
|
+
maxDepthLeft: maxDepth(leftHeavy.rects),
|
|
220
|
+
maxDepthTime: maxDepth(timeOrder.rects),
|
|
221
|
+
leftHeavy: leftHeavy.rects,
|
|
222
|
+
timeOrder: timeOrder.rects,
|
|
223
|
+
leftHeavyHidden: leftHeavy.hidden,
|
|
224
|
+
timeOrderHidden: timeOrder.hidden,
|
|
225
|
+
stats: frameStats(profile, frameCount),
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
/** The complete serializable model for one speedscope document. */
|
|
229
|
+
function buildFlameModel(doc, isSource = palette_1.hasSourceFile) {
|
|
230
|
+
const colors = frameColors(doc.shared.frames, isSource);
|
|
231
|
+
return {
|
|
232
|
+
frames: doc.shared.frames.map((frame, i) => ({
|
|
233
|
+
name: frame.name,
|
|
234
|
+
file: frame.file ?? "",
|
|
235
|
+
line: frame.line ?? 0,
|
|
236
|
+
color: colors[i],
|
|
237
|
+
source: isSource(frame.file ?? ""),
|
|
238
|
+
})),
|
|
239
|
+
fibers: doc.profiles.map((profile) => buildFiber(profile, doc.shared.frames.length)),
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=flame-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flame-model.js","sourceRoot":"","sources":["../../src/flame-model.ts"],"names":[],"mappings":";AAAA,kEAAkE;AAClE,+DAA+D;AAC/D,4EAA4E;AAC5E,0EAA0E;AAC1E,6EAA6E;AAC7E,4EAA4E;AAC5E,4EAA4E;AAC5E,+DAA+D;;;;;;;;;;AAE/D,yDAAoE;A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ACtB,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC;YACrB,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;YAChB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;SACnC,CAAC,CAAC;QACH,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;KACrF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fit `name` into `avail` pixels by carving characters out of the middle and
|
|
3
|
+
* inserting an ellipsis, using the caller's text `measure` (canvas
|
|
4
|
+
* measureText in the webview, an injected fake in tests). Returns the widest
|
|
5
|
+
* candidate that fits, or a lone ellipsis when nothing does.
|
|
6
|
+
*/
|
|
7
|
+
export declare function fitLabelText(name: string, avail: number, measure: (text: string) => number): string;
|
|
8
|
+
/** Case-insensitive substring match over frame names → set of frame indexes. */
|
|
9
|
+
export declare function searchMatches(frames: readonly {
|
|
10
|
+
name: string;
|
|
11
|
+
}[], query: string): Set<number>;
|
|
12
|
+
/**
|
|
13
|
+
* The share of the profile `slabs` cover, each instant counted once. Flame
|
|
14
|
+
* slabs nest or are disjoint, so this is the sum of the outermost matches —
|
|
15
|
+
* a match inside a matched slab adds nothing. One sort and one sweep, so a
|
|
16
|
+
* search over a whole budget of slabs stays interactive.
|
|
17
|
+
*/
|
|
18
|
+
export declare function coveredSpan(slabs: [number, number][]): number;
|
|
19
|
+
/**
|
|
20
|
+
* Clamp a flame-graph view window to config space: span forced into
|
|
21
|
+
* [minSpan, 1], then the window slid back inside [0, 1] preserving the span.
|
|
22
|
+
*/
|
|
23
|
+
export declare function clampViewRange(x0: number, x1: number, minSpan: number): {
|
|
24
|
+
x0: number;
|
|
25
|
+
x1: number;
|
|
26
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Pure helpers shared between the extension host and the flame-graph webview
|
|
3
|
+
// ([PROF-UI-SAMPLED]). FLAME_SCRIPT embeds these functions' COMPILED SOURCE
|
|
4
|
+
// via Function.prototype.toString, so the exact code the webview executes is
|
|
5
|
+
// type-checked and unit-tested here. Rules for anything in this file: no
|
|
6
|
+
// imports, no captured module state, no TS-only syntax that erases to
|
|
7
|
+
// different behavior — each function must be a self-contained declaration
|
|
8
|
+
// that serializes cleanly (target es2020; the webview is modern Chromium).
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.fitLabelText = fitLabelText;
|
|
11
|
+
exports.searchMatches = searchMatches;
|
|
12
|
+
exports.coveredSpan = coveredSpan;
|
|
13
|
+
exports.clampViewRange = clampViewRange;
|
|
14
|
+
/**
|
|
15
|
+
* Fit `name` into `avail` pixels by carving characters out of the middle and
|
|
16
|
+
* inserting an ellipsis, using the caller's text `measure` (canvas
|
|
17
|
+
* measureText in the webview, an injected fake in tests). Returns the widest
|
|
18
|
+
* candidate that fits, or a lone ellipsis when nothing does.
|
|
19
|
+
*/
|
|
20
|
+
function fitLabelText(name, avail, measure) {
|
|
21
|
+
// The fraction of the remaining name each mid-ellipsis step carves out.
|
|
22
|
+
const KEEP_SHRINK_RATIO = 0.15;
|
|
23
|
+
if (measure(name) <= avail) {
|
|
24
|
+
return name;
|
|
25
|
+
}
|
|
26
|
+
for (let keep = name.length; keep > 2;) {
|
|
27
|
+
keep -= Math.max(1, Math.ceil(keep * KEEP_SHRINK_RATIO));
|
|
28
|
+
const half = Math.floor(keep / 2);
|
|
29
|
+
const candidate = `${name.slice(0, half)}…${name.slice(name.length - (keep - half))}`;
|
|
30
|
+
if (measure(candidate) <= avail) {
|
|
31
|
+
return candidate;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return "…";
|
|
35
|
+
}
|
|
36
|
+
/** Case-insensitive substring match over frame names → set of frame indexes. */
|
|
37
|
+
function searchMatches(frames, query) {
|
|
38
|
+
const needle = query.trim().toLowerCase();
|
|
39
|
+
if (needle === "") {
|
|
40
|
+
return new Set();
|
|
41
|
+
}
|
|
42
|
+
return new Set(frames.flatMap((frame, i) => (frame.name.toLowerCase().includes(needle) ? [i] : [])));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The share of the profile `slabs` cover, each instant counted once. Flame
|
|
46
|
+
* slabs nest or are disjoint, so this is the sum of the outermost matches —
|
|
47
|
+
* a match inside a matched slab adds nothing. One sort and one sweep, so a
|
|
48
|
+
* search over a whole budget of slabs stays interactive.
|
|
49
|
+
*/
|
|
50
|
+
function coveredSpan(slabs) {
|
|
51
|
+
const sorted = slabs.toSorted((left, right) => left[0] - right[0]);
|
|
52
|
+
let covered = 0;
|
|
53
|
+
let reach = -Infinity;
|
|
54
|
+
for (const [x0, x1] of sorted) {
|
|
55
|
+
if (x1 > reach) {
|
|
56
|
+
covered += x1 - Math.max(x0, reach);
|
|
57
|
+
}
|
|
58
|
+
reach = Math.max(reach, x1);
|
|
59
|
+
}
|
|
60
|
+
return covered;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Clamp a flame-graph view window to config space: span forced into
|
|
64
|
+
* [minSpan, 1], then the window slid back inside [0, 1] preserving the span.
|
|
65
|
+
*/
|
|
66
|
+
function clampViewRange(x0, x1, minSpan) {
|
|
67
|
+
const span = Math.min(Math.max(x1 - x0, minSpan), 1);
|
|
68
|
+
const left = Math.min(Math.max(x0, 0), 1 - span);
|
|
69
|
+
return { x0: left, x1: left + span };
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=flame-script-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flame-script-helpers.js","sourceRoot":"","sources":["../../src/flame-script-helpers.ts"],"names":[],"mappings":";AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,6EAA6E;AAC7E,yEAAyE;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