* Get efficiency metrics.
()
| 39 | * Get efficiency metrics. |
| 40 | */ |
| 41 | getMetrics() { |
| 42 | const avgPromptPerCall = this.totalCalls > 0 ? Math.round(this.totalPrompt / this.totalCalls) : 0; |
| 43 | const avgCompletionPerCall = this.totalCalls > 0 ? Math.round(this.totalCompletion / this.totalCalls) : 0; |
| 44 | const totalTokens = this.totalPrompt + this.totalCompletion; |
| 45 | |
| 46 | // Efficiency: ratio of completion (useful output) to prompt (context overhead) |
| 47 | const efficiency = this.totalPrompt > 0 ? (this.totalCompletion / this.totalPrompt * 100).toFixed(1) : '0'; |
| 48 | |
| 49 | return { |
| 50 | totalCalls: this.totalCalls, |
| 51 | totalTokens, |
| 52 | totalPrompt: this.totalPrompt, |
| 53 | totalCompletion: this.totalCompletion, |
| 54 | avgPromptPerCall, |
| 55 | avgCompletionPerCall, |
| 56 | efficiency: `${efficiency}%`, // higher = more output per context token |
| 57 | turns: this.turns.length, |
| 58 | compactions: this.compactions, |
| 59 | evictions: this.evictions, |
| 60 | }; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Format for display. |
no outgoing calls
no test coverage detected