start_profiling
Initiate performance profiling to monitor memory consumption and execution time in PHP applications during debugging sessions.
Instructions
Start profiling to track memory usage and execution time
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/advanced.ts:225-239 (handler)Handler function for the 'start_profiling' tool. It invokes Profiler.startSession() to begin a new profiling session and returns success response with session ID.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/tools/advanced.ts:221-224 (registration)Registration of the 'start_profiling' MCP tool using server.tool(), with empty input parameters schema.server.tool( 'start_profiling', 'Start profiling to track memory usage and execution time', {},
- src/session/profiler.ts:52-69 (helper)Core implementation in Profiler.startSession(): creates and returns a new ProfilingSession object, ending any previous active session if exists.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; }