Saltar al contenido
Skillpedia
Programación general7,4 mil · #13233

instruments-profiling

Qué hace

Esta skill muestra cómo grabar una traza del Time Profiler de una app nativa de Apple y abrirla en Instruments. Está pensada para desarrolladores que investigan apps nativas lentas o muy pesadas.

Cuándo usarla

  • ✓Cuando una app de macOS o iOS va lenta y necesitas ver en qué se gasta el tiempo.
  • ✓Cuando necesitas una traza de una compilación concreta de la app y no de otra copia.
  • ✓Cuando quieres una grabación de rendimiento de una app desde la línea de comandos.

Link de la skill

https://github.com/steipete/agent-scripts/blob/main/skills/instruments-profiling/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/steipete/agent-scripts/blob/main/skills/instruments-profiling/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Mi app de Mac va lenta al abrir un proyecto. Graba una traza de rendimiento y muéstrame dónde se va el tiempo.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

El agente graba una traza con la herramienta de línea de comandos xctrace, asociada al binario correcto de la app, y abre el resultado en Instruments para analizar las pilas.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

Instruments Profiling (macOS/iOS)

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.

Quick Start (CLI)

  • 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):
    • Launch app yourself, get PID, then:
    • 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. Use these rules:

  • Prefer direct binary path for deterministic launch:
    • xcrun xctrace record ... --launch -- /path/App.app/Contents/MacOS/App
  • If launching .app, ensure it’s the intended bundle:
    • open -n /path/App.app
    • Verify with ps -p <pid> -o comm= -o command=
  • If both /Applications/App.app and a local build exist, explicitly target the local build path.
  • After launch, confirm the process path before trusting the trace.

Command Arguments (xctrace)

  • --template 'Time Profiler': template name from xctrace list templates.
  • --launch -- <cmd>: everything after -- is the target command (binary or app bundle).
  • --attach <pid|name>: attach to running process.
  • --output <path>: .trace output. If omitted, file saved in CWD.
  • --time-limit 60s|5m: set capture duration.
  • --device <name|UDID>: required for iOS device runs.
  • --target-stdout -: stream launched process stdout to terminal (useful for CLI tools).

Exporting Stacks (CLI)

  • 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
  • Post-process in a script (Python/Rust) to aggregate stacks.

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: LaunchServices resolves installed app instead of local build.
    • Fix: use direct binary path or --attach with known PID.
  • No samples / empty trace: App exits quickly or never hits work.
    • Fix: longer capture, trigger workload during recording.
  • Privacy prompts: xctrace may need Developer Tools permission.
    • Fix: System Settings → Privacy & Security → Developer Tools → allow Terminal/Xcode.
  • Large XML exports: time-profile exports are huge.
    • Fix: filter with XPath and aggregate offline; don’t print to terminal.

iOS Specific Notes

  • Device: use xcrun xctrace list devices and --device <UDID>.
  • Launch via Xcode if needed; attach with xctrace --attach.
  • 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.
Preguntas frecuentes

¿Por qué se podría perfilar la app equivocada?

La skill advierte de que macOS puede resolver otra copia de la app, por eso recomienda apuntar a la ruta exacta del binario.

¿Cuánto dura una grabación?

Los ejemplos usan un límite de tiempo, como 60 segundos.

¿Puede conectarse a una app que ya está abierta?

Sí. La skill describe cómo conectarse a un ID de proceso después de abrir la app.

Detalles

Descripción original del autor

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

repo: steipete/agent-scripts

Popularidad

Estrellas en GitHub
7,4 mil
Posición en el ranking
#13233
Licencia
MIT
Actualizada
30/10/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas