gui-elements.ts: Add chart function (e.g.,makeAwaitPie) following existing patternsscalene-gui.ts:- Add to imports
- Add chart array (e.g.,
const await_pies: (unknown | null)[] = []) - Add column in
makeTableHeader() - Add cell rendering in
makeProfileLine()— push chart specs to array - Pass array through both call sites (line profile loop + function profile loop)
- Add
embedCharts(await_pies, "await_pie")at the end
- Rebuild:
npx esbuild scalene-gui.ts --bundle --outfile=scalene-gui-bundle.js --format=iife --global-name=ScaleneGUI scalene_json.py: Add field toFunctionDetail, compute in payloadscalene_output.py: Add column for CLI--htmloutputscalene_parseargs.py: Add column in_display_profile_cli()forscalene view --cli
All charts are Vega-Lite specs rendered via vegaEmbed() after DOM insertion.
- Bar:
makeBar()— stacked horizontal bar (CPU time: Python/native/system) - Pie:
makeGPUPie(),makeAwaitPie(),makeMemoryPie()— arc charts - Sparkline:
makeSparkline()— line chart for memory timeline - NRT/NC bars:
makeNRTBar(),makeNCTimeBar()— Neuron time bars - Standard dimensions: 20px height, various widths
- Always use two data values (filled + remaining) for a complete circle. Single-value pies with
scale: { domain: [0, 100] }show partial arcs with gaps — looks bad. - For rotating pies (each row's wedge starts where previous ended): use
scale: { range: [startAngle, startAngle + 2*PI] }on the theta encoding. Track cumulative angle:pieAngles.await += (pct / 100) * 2 * Math.PI;
- Reset angle state per table (line profile and function profile tables get separate
pieAnglesobjects).
makeProfileLine()builds HTML string with<span id="chart_name${index}">placeholders- Chart specs are pushed to arrays (e.g.,
cpu_bars,gpu_pies,await_pies) - After all HTML is inserted into DOM,
embedCharts(array, "prefix")callsvegaEmbed()for each spec - SVGs render asynchronously — Selenium tests need explicit waits to verify SVG content
This function has many parameters. When adding new ones, append to the end with defaults. The two call sites are:
- Line profile loop: creates
linePieAngles = { await: 0, gpu: 0 }before the loop - Function profile loop: creates
fnPieAngles = { await: 0, gpu: 0 }before the loop