Profiling
Testing & QualityprofilingProfiling is an Agent Skill for testing & quality published in the leanprover/lean4 repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Profile Lean programs with demangled names using samply and Firefox Profiler. Use when the user asks to profile a Lean binary or investigate performance.
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/leanprover/lean4/blob/HEAD/.claude/skills/profiling/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/profiling, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Profiling Lean Programs
Full documentation: script/PROFILER_README.md.
Quick Start
script/lean_profile.sh ./build/release/stage1/bin/lean some_file.lean
Requires samply (cargo install samply) and python3.
Agent Notes
- The pipeline is interactive (serves to browser at the end). When running non-interactively, run the steps manually instead of using the wrapper script.
- The three steps are:
samply record --save-only,symbolicate_profile.py, thenserve_profile.py. lean_demangle.pyworks standalone as a stdin filter (likec++filt) for quick name lookups.- The
--rawflag onlean_demangle.pygives exact demangled names without postprocessing (keeps._redArg,._lam_0suffixes as-is). - Use
PROFILE_KEEP=1to keep the temp directory for later inspection. - The demangled profile is a standard Firefox Profiler JSON. Function names live in
threads[i].stringArray, indexed bythreads[i].funcTable.name.