start_profiling
Initiate performance profiling to monitor memory consumption and execution time during PHP debugging sessions.
Instructions
Start profiling to track memory usage and execution time
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {},
"type": "object"
}
Implementation Reference
- src/tools/advanced.ts:221-239 (registration)Registers the start_profiling MCP tool, providing description, empty input schema, and an inline handler that calls Profiler.startSession() and returns success response with session ID.server.tool( 'start_profiling', 'Start profiling to track memory usage and execution time', {}, async () => { const session = ctx.profiler.startSession(); return { content: [ { type: 'text', text: JSON.stringify({ success: true, sessionId: session.id, message: 'Profiling started. Use step commands to collect data.', }), }, ], }; }
- src/session/profiler.ts:52-69 (helper)Core implementation of startSession() in Profiler class, which initializes and returns a new ProfilingSession object for tracking profiling data.startSession(): ProfilingSession { if (this.currentSession && !this.currentSession.endedAt) { this.endSession(); } this.currentSession = { id: `profile_${++this.sessionIdCounter}`, startedAt: new Date(), snapshots: [], functionProfiles: new Map(), totalMemorySnapshots: 0, peakMemoryUsage: 0, }; this.lastSnapshotTime = Date.now(); logger.info(`Profiling session started: ${this.currentSession.id}`); return this.currentSession; }