Skip to content

Time Profile and Usage Profile: opt-in top-10 legend; optional region labels - #153

Merged
ritvikrao merged 8 commits into
mainfrom
profile-legends
Jul 27, 2026
Merged

Time Profile and Usage Profile: opt-in top-10 legend; optional region labels#153
ritvikrao merged 8 commits into
mainfrom
profile-legends

Conversation

@lvkale

@lvkale lvkale commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Time Profile: adds a "Show Legend (top 10)" checkbox to the bottom control panel. It opens a movable legend window (draggable over an empty part of the chart) capped at the 10 largest activities in the displayed range, each labeled with its percentage of total time and using shortened entry names. Idle and Overhead are omitted from the compact legend — their colors are fixed and familiar to viewers — while the existing Legend menu still provides the full list including them. Closing the legend window unchecks the box; loading a new time/PE range refreshes the legend in place. The compact legend is displayed in chart order: entries are selected by size but listed by their utilization-weighted mean interval (time centroid), so for phase-like entry methods the legend reads top-to-bottom in the same order the phases appear left-to-right in the chart. The Legend menu's full list stays size-sorted.
  • Time Profile region labels: adds a separate opt-in "Label Regions" checkbox (independent of the legend, so exported images can use either or both). Entry methods whose utilization share stays ≥25 percentage points for ≥1/20 of the displayed intervals get their name drawn directly on the chart, centered in their stacked band, and ellipsis-truncated in narrow regions. Label text is black on light regions and white on dark ones (perceived-luminance test on the entry's color). EPs labeled on the chart are omitted from the compact legend to free slots. Implemented via a reusable Graph.setRegionLabels() hook following the existing setMarkers() pattern.
  • Usage Profile: the same top-10 legend feature, as a "Top 10" checkbox in a titled panel matching the existing Grid control. Entries are ranked by average utilization over the selected PEs (matching the Avg bar, and matching the bars' bottom-to-top stacking order); IDLE is omitted, PACKING/UNPACKING remain eligible. The legend refreshes on range reload and color changes. Also fixes actionPerformed to check which checkbox fired instead of assuming any checkbox event is the grid toggle. (No region labels here: per-processor bars are too narrow for on-chart text.)
  • Refactor: Legend moves from projections.Tools.TimeProfile to projections.gui as a public class so both tools (and future ones) can use it; it gains a window title and getFrame()/dispose() for lifecycle management. Its rendering is unchanged, including click-to-save-PNG.
  • gitignore: adds *.projrc (written by Projections next to any opened trace, e.g. test/hello.projrc after a local make test) and .DS_Store.

Testing

Built with gradle copyJarToBin (JDK 17) and exercised against a 120-PE trace: both tools' legends show the top-10 with percentages, follow range reloads, restore their position on refresh, and keep the checkbox in sync when the window is closed directly. The Time Profile legend lists phases in left-to-right chart order. Region labels appear on the dominant phases with contrast-appropriate text color, truncate in narrow regions, recompute on range reload, toggle off cleanly, and remove their EPs from the legend while active. The Legend menu behavior in Time Profile is unchanged.

🤖 Generated with Claude Code

lvkale and others added 3 commits July 26, 2026 20:10
Projections writes a .projrc next to any trace it opens (including
test/hello.projrc after a local 'make test'), which shows up as
untracked noise.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The existing Legend menu items are easy to miss and list every entry
above 0.5% of the total, which can be tens of lines. Add a
"Show Legend (top 10)" checkbox to the control panel that opens a
movable legend window capped at the 10 largest activities in the
displayed range, each labeled with its percentage of total time.
Idle and Overhead are omitted from the compact legend: their colors
are fixed and familiar to viewers. Unchecking the box (or closing the
window, which unchecks it) dismisses the legend, and loading a new
time/PE range refreshes it in place. The Legend menu still shows the
full list including Idle and Overhead.

To support this, Legend moves to projections.gui as a public class
usable by other tools, gains a window title, and exposes
getFrame()/dispose() so callers can manage its lifecycle.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Same feature as the Time Profile legend: a "Top 10" checkbox (in a
titled panel matching the Grid control) opens a movable legend window
listing the 10 largest activities ranked by average utilization over
the selected PEs, matching the Avg bar. IDLE is omitted since its
color is fixed and familiar; PACKING and UNPACKING remain eligible.
The legend refreshes when a new range is loaded or colors change, and
closing the window unchecks the box.

Also fix actionPerformed to check which checkbox fired instead of
assuming any JCheckBox event is the grid toggle.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@lvkale
lvkale requested a review from matthiasdiener as a code owner July 27, 2026 01:11
@lvkale
lvkale requested a review from ericjbohm July 27, 2026 01:11
Add a "Label Large Regions" checkbox (opt-in, independent of the
legend so exported images can use either or both). When enabled, any
entry method whose utilization share stays at or above 25 percentage
points for at least 1/20 of the displayed intervals gets its shortened
name drawn at the center of that run, vertically centered in its
stacked band. Labels are drawn in black with a white halo so they read
on any region color, are truncated with an ellipsis in narrow regions,
and are skipped entirely when almost nothing fits. Entry methods
labeled on the chart are omitted from the compact top-10 legend to
free slots for smaller activities; the Legend menu's full list is
unaffected. Labels recompute on range reload and toggle off cleanly.

The drawing support is a reusable Graph.setRegionLabels() hook in
projections.gui.graph.Graph, following the setMarkers() pattern, so
other stacked-graph tools can adopt it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@lvkale lvkale changed the title Time Profile and Usage Profile: opt-in top-10 legend Time Profile and Usage Profile: opt-in top-10 legend; optional region labels Jul 27, 2026
lvkale and others added 2 commits July 26, 2026 21:27
Plain text reads cleaner than haloed text. Draw region labels in black
on light regions and white on dark ones (perceived-luminance test on
the EP color, which RegionLabel now carries). Also shorten the
checkbox text to "Label Regions".

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Selection into the top-10 legend is still by total time, but the
entries are displayed in order of their utilization-weighted mean
interval (time centroid), so for phase-like entry methods the legend
reads top-to-bottom in the same order the phases appear left-to-right
in the chart. An entry method active throughout the run lands near
the middle, which is benign. The Legend menu's full list stays sorted
by size.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ritvikrao
ritvikrao self-requested a review July 27, 2026 14:27
ritvikrao
ritvikrao previously approved these changes Jul 27, 2026
@ritvikrao
ritvikrao self-requested a review July 27, 2026 18:06
@ritvikrao
ritvikrao merged commit 4691999 into main Jul 27, 2026
2 checks passed
@ritvikrao
ritvikrao deleted the profile-legends branch July 27, 2026 18:07
ritvikrao pushed a commit that referenced this pull request Jul 27, 2026
The #153 squash fixed the file format (owners must share one line;
with separate "*" lines only the last one counts) but dropped
matthiasdiener, who continues to contribute and review. Add ericjbohm,
a regular reviewer, as well. All four are co-owners: any of them is
auto-requested for review on every PR.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants