From 37a08e7b43cdfef5dc2aee7a319a6786bc449e3f Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 12 Oct 2026 21:11:28 +0200 Subject: [PATCH] Add a chart values achievement. --- profiler/CMakeLists.txt | 1 + profiler/src/achievements/Plots.md | 7 +++++++ profiler/src/profiler/TracyAchievementData.cpp | 8 ++++++++ profiler/src/profiler/TracyTimelineItemPlot.cpp | 5 +++++ profiler/src/profiler/TracyTimelineItemPlot.hpp | 1 + 5 files changed, 22 insertions(+) create mode 100644 profiler/src/achievements/Plots.md diff --git a/profiler/CMakeLists.txt b/profiler/CMakeLists.txt index be5ff535..f337b0e8 100644 --- a/profiler/CMakeLists.txt +++ b/profiler/CMakeLists.txt @@ -219,6 +219,7 @@ Embed(PROFILER_FILES TextInstrumentFrames src/achievements/InstrumentFrames.md T Embed(PROFILER_FILES TextIntro src/achievements/Intro.md TEXT) Embed(PROFILER_FILES TextLoadTrace src/achievements/LoadTrace.md TEXT) Embed(PROFILER_FILES TextManual src/achievements/Manual.md TEXT) +Embed(PROFILER_FILES TextPlots src/achievements/Plots.md TEXT) Embed(PROFILER_FILES TextSamplingIntro src/achievements/SamplingIntro.md TEXT) Embed(PROFILER_FILES TextSaveTrace src/achievements/SaveTrace.md TEXT) Embed(PROFILER_FILES TextSections src/achievements/Sections.md TEXT) diff --git a/profiler/src/achievements/Plots.md b/profiler/src/achievements/Plots.md new file mode 100644 index 00000000..d57dc3b7 --- /dev/null +++ b/profiler/src/achievements/Plots.md @@ -0,0 +1,7 @@ +# Chart values + +Some questions are not about how long things take, but about how a number changes over time: draw calls per frame, queries in flight, queue depth. Use [plots](#plottingdata): `TracyPlot( "draw calls", count )` reports one point each time it is called, and the points become a plot lane below the threads in the timeline, where spikes and trends are easy to spot at a glance. Middle-click the plot header to zoom the view straight to the range the plot has recorded. + +`TracyPlotConfig( name, type, step, fill, color )` is optional: pick a number format (`Number`, `Memory`, `Percentage`), hold values as a staircase instead of a smooth line, fill the area under the curve, or set the line color. + +Pick a number that matters to your application, report it with `TracyPlot`, then middle-click the plot header to see its full span. Try it out! diff --git a/profiler/src/profiler/TracyAchievementData.cpp b/profiler/src/profiler/TracyAchievementData.cpp index 9b4d208c..c1ee17de 100644 --- a/profiler/src/profiler/TracyAchievementData.cpp +++ b/profiler/src/profiler/TracyAchievementData.cpp @@ -15,6 +15,7 @@ #include "data/TextIntro.hpp" #include "data/TextLoadTrace.hpp" #include "data/TextManual.hpp" +#include "data/TextPlots.hpp" #include "data/TextSamplingIntro.hpp" #include "data/TextSections.hpp" #include "data/TextSaveTrace.hpp" @@ -82,12 +83,19 @@ AchievementItem ai_markSections = { .text = Unpack( TextSections ) }; +AchievementItem ai_chartValues = { + .id = "chartValues", + .name = "Chart values", + .text = Unpack( TextPlots ) +}; + AchievementItem* ac_instrumentationIntroItems[] = { &ai_100million, &ai_instrumentationStatistics, &ai_findZone, &ai_annotateZones, &ai_markSections, + &ai_chartValues, nullptr }; diff --git a/profiler/src/profiler/TracyTimelineItemPlot.cpp b/profiler/src/profiler/TracyTimelineItemPlot.cpp index 07689ccc..a4cb1560 100644 --- a/profiler/src/profiler/TracyTimelineItemPlot.cpp +++ b/profiler/src/profiler/TracyTimelineItemPlot.cpp @@ -25,6 +25,11 @@ bool TimelineItemPlot::IsEmpty() const return m_plot->data.empty(); } +void TimelineItemPlot::HeaderZoomed() +{ + if( s_config.achievements ) m_view.Achieve( "chartValues" ); +} + const char* TimelineItemPlot::HeaderLabel() const { static char tmp[1024]; diff --git a/profiler/src/profiler/TracyTimelineItemPlot.hpp b/profiler/src/profiler/TracyTimelineItemPlot.hpp index 410f3e83..3ad40509 100644 --- a/profiler/src/profiler/TracyTimelineItemPlot.hpp +++ b/profiler/src/profiler/TracyTimelineItemPlot.hpp @@ -26,6 +26,7 @@ protected: void HeaderTooltip( const char* label ) const override; void HeaderExtraContents( const TimelineContext& ctx, int offset, float labelWidth ) override; + void HeaderZoomed() override; bool DrawContents( const TimelineContext& ctx, int& offset ) override; void DrawFinished() override;