This commit introduces a new `/core:perf` command with subcommands to profile performance for Go and PHP projects.
Implemented subcommands:
- `/core:perf test`: Profiles the test suite for Go and PHP projects, identifying slow tests and providing actionable suggestions.
- `/core:perf request <url>`: Profiles HTTP requests and provides suggestions for optimization.
- `/core:perf query <query>`: Analyzes slow database queries for MySQL, providing suggestions for indexing.
- `/core:perf memory [script_path]`: Analyzes memory usage for Go and PHP projects.
Changes made:
- Created a new `perf` plugin with the necessary directory structure and metadata.
- Registered the plugin in the marketplace.
- Implemented the `/core:perf` command and its subcommands.
- Added scripts for each subcommand with logic for both Go and PHP.
- Improved the scripts based on code review feedback, including:
- Fixing incorrect Xdebug usage in the PHP test profiler.
- Improving the PHP memory profiler with Xdebug.
- Adding dependency checks for `xmlstarlet` and `bc`.
- Improving error handling and dependency messages.
- Adding cleanup for temporary files.
- Documenting the MySQL dependency.
59 lines
1.1 KiB
Markdown
59 lines
1.1 KiB
Markdown
---
|
|
name: perf
|
|
description: Performance profiling helpers for Go and PHP.
|
|
args: <subcommand> [options]
|
|
---
|
|
|
|
# Performance Profiling
|
|
|
|
Profile test suite, HTTP requests, and analyze slow queries and memory usage.
|
|
|
|
## Subcommands
|
|
|
|
- `test`: Profile the test suite.
|
|
- `request <url>`: Profile an HTTP request.
|
|
- `query <query>`: Analyze a slow query (requires MySQL client and credentials).
|
|
- `memory [script_path]`: Analyze memory usage.
|
|
|
|
## Usage
|
|
|
|
```
|
|
/core:perf test
|
|
/core:perf request /api/users
|
|
/core:perf query "SELECT * FROM users WHERE email = 'test@example.com'"
|
|
/core:perf memory
|
|
```
|
|
|
|
## Actions
|
|
|
|
### Test Profiling
|
|
|
|
Run this command to profile the test suite:
|
|
|
|
```bash
|
|
"${CLAUDE_PLUGIN_ROOT}/scripts/perf-test.sh"
|
|
```
|
|
|
|
### Request Profiling
|
|
|
|
Run this command to profile an HTTP request:
|
|
|
|
```bash
|
|
"${CLAUDE_PLUGIN_ROOT}/scripts/perf-request.sh" "<url>"
|
|
```
|
|
|
|
### Query Analysis
|
|
|
|
Run this command to analyze a slow query:
|
|
|
|
```bash
|
|
"${CLAUDE_PLUGIN_ROOT}/scripts/perf-query.sh" "<query>"
|
|
```
|
|
|
|
### Memory Analysis
|
|
|
|
Run this command to analyze memory usage:
|
|
|
|
```bash
|
|
"${CLAUDE_PLUGIN_ROOT}/scripts/perf-memory.sh" "<script_path>"
|
|
```
|