get_profile_stats
Retrieve current profiling statistics for PHP applications to analyze performance and identify bottlenecks during debugging sessions.
Instructions
Get current profiling statistics
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:265-276 (handler)Handler function for the 'get_profile_stats' tool. Retrieves profiling statistics from ctx.profiler.getStatistics() and returns them as formatted JSON text content, or an error message if no profiling data is available.async () => { const stats = ctx.profiler.getStatistics(); if (!stats) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'No profiling data. Start profiling first.' }) }], }; } return { content: [{ type: 'text', text: JSON.stringify(stats, null, 2) }], }; }
- src/tools/advanced.ts:261-277 (registration)Registration of the 'get_profile_stats' MCP tool using server.tool(), including description, empty input schema, and inline handler.server.tool( 'get_profile_stats', 'Get current profiling statistics', {}, async () => { const stats = ctx.profiler.getStatistics(); if (!stats) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'No profiling data. Start profiling first.' }) }], }; } return { content: [{ type: 'text', text: JSON.stringify(stats, null, 2) }], }; } );
- src/tools/advanced.ts:264-264 (schema)Input schema for 'get_profile_stats': no input parameters required (empty object).{},
- src/session/profiler.ts:171-200 (helper)Profiler.getStatistics() method invoked by the tool handler. Computes and returns detailed profiling statistics including session ID, activity status, duration, snapshot count, peak memory usage, function count, and top 10 functions by total execution time.getStatistics(): { sessionId: string | null; isActive: boolean; duration: number; snapshotCount: number; peakMemoryUsage: number; functionCount: number; topFunctions: FunctionProfile[]; } | null { if (!this.currentSession) return null; const duration = this.currentSession.endedAt ? this.currentSession.endedAt.getTime() - this.currentSession.startedAt.getTime() : Date.now() - this.currentSession.startedAt.getTime(); const functions = Array.from(this.currentSession.functionProfiles.values()); const topFunctions = functions .sort((a, b) => b.totalTime - a.totalTime) .slice(0, 10); return { sessionId: this.currentSession.id, isActive: !this.currentSession.endedAt, duration, snapshotCount: this.currentSession.snapshots.length, peakMemoryUsage: this.currentSession.peakMemoryUsage, functionCount: functions.length, topFunctions, }; }