| Crates.io | thag_demo |
| lib.rs | thag_demo |
| version | 0.2.1 |
| created_at | 2025-10-17 07:29:29.576042+00 |
| updated_at | 2025-10-17 17:07:42.776459+00 |
| description | Interactive demos for thag_rs and thag_profiler - run Rust profiling examples without installing thag |
| homepage | |
| repository | https://github.com/durbanlegend/thag_rs |
| max_upload_size | |
| id | 1887247 |
| size | 361,739 |
Interactive demos for thag_rs and thag_profiler - run Rust profiling examples without installing thag!
One-line demo experience:
curl -sL https://raw.githubusercontent.com/durbanlegend/thag_rs/main/thag_demo/install_and_demo.sh | bash
Or install manually:
cargo install thag_demo
thag_demo --list
thag_demo is a lightweight facade over thag_rs that provides curated profiling examples and demonstrations. It's designed to let you explore the capabilities of thag_profiler without needing to install the full thag_rs toolkit.
thag_demo basic-profiling
Learn the fundamentals of function timing and profiling with the #[profiled] attribute.
thag_demo time-profiling
Execution time profiling of nested functions with automatic flamegraph generation and browser visualization.
Click to watch: The demo shows building and running an instrumented program, then generating an interactive flamegraph
Type thag_demo to show the welcome screen showing options.
Type thag_demo time-profiling to invoke the time profiling demo.
Builds (if needed) and runs a sample program instrumented with thag_profiler execution time profiling.
Offers to show a flamegraph of the results. Respond βyβ.
Displays collected stats while it builds and shows the flamegraph in the browser.
The flamegraph is not recorded by the asciinema recorder because the latter is terminal-based, but is shown both as PNG and interactive SVG in thag_demo README.md.
End of demo.

Interactive flamegraph showing execution time across nested function calls. Click image for interactive version with clickable bars and search.
Hover to see details and see the following displayed for each one as a tooltip and also in the bottom area:
a. function name, preceded by async if applicable
b. elapsed time in microseconds
c. percentage of total elapsed time that this bar accounts for.
Search for functions Find functions whose names contain _a:
Search link in the top right corner, enter _a in the dialog that pops up, and press Enter. Bars with matching text will display in pink. Notice that matching functions appear in three different places stacks.Expand bars and undo Click on one of the pink bars and see how it expands to the full width of the screen, with its call stack below it.
Click on the main or all bar at the bottom to restore the full view.
Click on another of the pink bars and see it do the same, showing its slightly different call stack below it.
Reset view To remove the pink highlighting, click on the Reset link.
thag_demo memory-profiling
Explore memory allocation tracking, heap analysis, and memory flamegraphs.
thag_demo async-profiling
Discover how to profile async functions, futures, and Tokio runtime integration.
thag_demo comparison
See before/after performance analysis with differential profiling techniques.
thag_demo flamegraph
Generate and understand interactive flamegraphs for visual performance analysis.
thag_demo benchmark
Run a full-featured benchmark showcasing all profiling capabilities.
thag_demo browse
Browse and run demo scripts interactively with filtering and search.
Click to watch: The demo shows running thag_demo browse to view all the thag scripts in $THAG_DEMO_DIR, and selecting and running the ratatui showcase demo. It also highlights the use of thag_styling integrations to automatically theme both the inquire selection list and the ratatui showcase screen with the current catppuccin-mocha theme.
Invoke thag_demo with the browse option.
Inquire crate displays themed scrollable list of thag demo scripts.
Type rata to narrow the search on the fly.
Arrow down to select ratatui_theming_showcase script.
Enter to invoke run options for the script.
Final Enter builds script if needed and runs it.
Demo shows ratatui showcase app, themed by thag_styling with the terminalβs current catppuccin-mocha theme, as specified by $THAG_THEME.
Show first panel of app with progress bar responding to keys or mouse. The dashed vertical border effect in some areas is an artefact of the video player.
Show pop-up help.
Show remaining 3 panels in turn.
Enter q to return to thag_demo browse.
Esc to end thag_demo browse.
thag_demo list-scripts
See all available demo scripts with descriptions and categories.
thag_demo manage
Download, update, or manage the demo script collection.
thag_demo script <script_name>
Run any script from the thag_rs demo collection.
#[profiled]thag_demo is a thin wrapper around thag_rs that:
The tool automatically searches for demo scripts in multiple locations:
Sibling to thag_demo installation
~/.thag/demo (standard user location)
$THAG_DEMO_DIR environment variable
./demo in current directory
If not found, it offers to download the demo collection using thag_get_demo_dir.
thag_demo browse
thag_demo manage
thag_demo list-scripts
Each demo generates several files you can explore:
*.svg - Interactive flamegraphs (open in browser)*.folded - Raw profile data for analysisAll demos use thag_profiler annotations:
use thag_profiler::{enable_profiling, profiled};
#[profiled]
fn my_function() {
// Your code here
}
#[enable_profiling(time)]
fn main() {
my_function();
}
After running the demos:
.svg files in your browserLicensed under either of
at your option.
Contributions will be considered (under MIT/Apache 2 license) if they align with the aims of the project.
Rust code should pass clippy::pedantic checks.