diff --git a/.claude/skills/piker_profiling.md b/.claude/skills/piker_profiling.md new file mode 100644 index 00000000..5e6bacac --- /dev/null +++ b/.claude/skills/piker_profiling.md @@ -0,0 +1,384 @@ +# Piker Profiling Subsystem Skill + +Skill for using `piker.toolz.profile.Profiler` to measure +performance across distributed actor systems. + +## Core Profiler API + +### Basic Usage + +```python +from piker.toolz.profile import ( + Profiler, + pg_profile_enabled, + ms_slower_then, +) + +profiler = Profiler( + msg='', + disabled=False, # IMPORTANT: enable explicitly! + ms_threshold=0.0, # show all timings, not just slow +) + +# do work +some_operation() +profiler('step 1 complete') + +# more work +another_operation() +profiler('step 2 complete') + +# prints on exit: +# > Entering +# step 1 complete: 12.34, tot:12.34 +# step 2 complete: 56.78, tot:69.12 +# < Exiting , total: 69.12 ms +``` + +### Default Behavior Gotcha + +**CRITICAL:** Profiler is disabled by default in many contexts! + +```python +# BAD: might not print anything! +profiler = Profiler(msg='my operation') + +# GOOD: explicit enable +profiler = Profiler( + msg='my operation', + disabled=False, # force enable! + ms_threshold=0.0, # show all steps +) +``` + +### Profiler Output Format + +``` +> Entering +