Skip to content
Back to skills

Instruments Profiling

ASecurity

Instruments/xctrace profiling: macOS/iOS traces, binaries, args, exports, Time Profiler.

  • 10 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 10, 2026
ai-agentsrustgobashgitsecurityperformance

Works with

  • terminal
  • cli

Security analysis

A100/100

Scanned October 10, 2026

npx -y skills add mouadja02/skills --skill instruments-profiling --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Instruments Profiling?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Instruments Profiling
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/mouadja02-instruments-profiling/badge)](https://www.skillsdirectory.com/skills/mouadja02-instruments-profiling)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: instruments-profiling
description: "Instruments/xctrace profiling: macOS/iOS traces, binaries, args, exports, Time Profiler."
source: "https://github.com/steipete/agent-scripts"
attribution: "steipete/agent-scripts by Peter Steinberger"
version: "1.0.1"
platform: apple
---

# Instruments Profiling (macOS/iOS)

> **Attribution:** Sourced from [steipete/agent-scripts](https://github.com/steipete/agent-scripts) by [Peter Steinberger](https://github.com/steipete).

Use this skill when the user wants performance profiling or stack analysis for native apps.
Focus: Time Profiler, `xctrace` CLI, and picking the correct binary/app instance.

**Related skill:** For CLI-only hotspot analysis without opening Instruments, see [native-app-performance](https://github.com/mouadja02/skills/tree/main/skills/coding/native-app-performance).

## When to Use

```bash
# List templates
xcrun xctrace list templates

# Record Time Profiler (launch)
xcrun xctrace record --template 'Time Profiler' --time-limit 60s --output /tmp/App.trace --launch -- /path/To/App.app

# Record Time Profiler (attach)
xcrun xctrace record --template 'Time Profiler' --time-limit 60s --output /tmp/App.trace --attach <pid>

# Open trace in Instruments
open -a Instruments /tmp/App.trace
```

Note: `xcrun xctrace --help` is not a valid subcommand. Use `xcrun xctrace help record`.

## Picking the Correct Binary (Critical)

**Gotcha: Instruments may profile the wrong app** (e.g., one in `/Applications`) if LaunchServices resolves a different bundle.

- Prefer direct binary path for deterministic launch:
  - `xcrun xctrace record ... --launch -- /path/App.app/Contents/MacOS/App`
- After launch, confirm the process path before trusting the trace.

## Command Arguments

- `--template 'Time Profiler'`: template name from `xctrace list templates`.
- `--launch -- <cmd>`: everything after `--` is the target command.
- `--attach <pid|name>`: attach to running process.
- `--output <path>`: `.trace` output.
- `--time-limit 60s|5m`: set capture duration.
- `--device <name|UDID>`: required for iOS device runs.

## Exporting Stacks (CLI)

```bash
# Inspect trace tables
xcrun xctrace export --input /tmp/App.trace --toc

# Export raw time-profile samples
xcrun xctrace export --input /tmp/App.trace \
  --xpath '/trace-toc/run[@number="1"]/data/table[@schema="time-profile"]' \
  --output /tmp/time-profile.xml
```

## Instruments UI Workflow

- Template: Time Profiler
- Use "Record" and capture the slow path (startup vs steady-state)
- Call Tree tips:
  - Hide System Libraries
  - Invert Call Tree
  - Separate by Thread
  - Focus on hot frames and call counts

## Gotchas & Fixes

- **Wrong app profiled**: Use direct binary path or `--attach` with known PID.
- **No samples / empty trace**: Longer capture, trigger workload during recording.
- **Privacy prompts**: System Settings → Privacy & Security → Developer Tools → allow Terminal/Xcode.
- **Large XML exports**: Filter with XPath and aggregate offline; don't print to terminal.

## iOS Specific Notes

- Device: use `xcrun xctrace list devices` and `--device <UDID>`.
- Ensure debug symbols for meaningful stacks.

## Verification Checklist

- [ ] Confirm trace process path matches target build
- [ ] Confirm stacks show expected app frames
- [ ] Capture covers the slow operation (startup/refresh)
- [ ] Export stacks for automated diffing if optimizing

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…