MCPcopy
hub / github.com/Doorman11991/smallcode / getMetrics

Method getMetrics

bin/token_monitor.js:41–61  ·  view source on GitHub ↗

* Get efficiency metrics.

()

Source from the content-addressed store, hash-verified

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.

Callers 3

formatShortMethod · 0.95
formatFullMethod · 0.95
commands.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected