# Performance Analysis

> Use when investigating slow execution, high memory usage, or excessive token consumption. Systematic measurement before optimization.

- Skill: `voidful/performance-analysis` (Agent Skill)
- Install (CLI): `npx skillmds@latest add voidful/performance-analysis`
- Raw SKILL.md: https://api.skillmd.com/api/skills/voidful/performance-analysis/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- License: Apache-2.0
- Author: voidful (https://skillmd.com/u/voidful)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/voidful/performance-analysis

---


# Performance Analysis

## Core Principle

Measure first, optimize second. Never optimize based on intuition. Profiling data decides what to fix.

## Two Performance Dimensions in Agent Systems

### 1. Runtime Performance (Rust code)

Standard profiling applies:

```bash
# Compile with debug symbols for profiling
cargo build --release
# Use system profiler (Linux)
perf record ./target/release/aixlarity exec "task"
perf report
```

### 2. Token Performance (LLM usage)

This is unique to agent systems. Every token costs money and latency.

Metrics to track:
- **Prompt tokens per turn** — Is the context bloated?
- **Completion tokens per turn** — Is the model over-generating?
- **Tool calls per task** — Are there wasted tool calls (reading irrelevant files)?
- **Total cost per task** — Aixlarity tracks this automatically per session.

## Common Token Waste Patterns

- **Context stuffing**: Injecting too many files via `@{...}` when only one is needed.
- **Skill catalog bloat**: Too many skills listed in the prompt. Use Progressive Disclosure.
- **History accumulation**: Long conversations without auto-compact triggering.
- **Redundant tool calls**: Agent reads the same file multiple times across turns.

## When to Use

- When a task takes noticeably more tokens than expected.
- When `auto-compact` triggers frequently (sign of context pressure).
- Before adding new context sources to the prompt assembly.

