MCPcopy Create free account
hub / github.com/WebMCP-org/chrome-devtools-quickstart / createTokenAccumulator

Function createTokenAccumulator

benchmark/helpers.ts:368–408  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

366 * ```
367 */
368export function createTokenAccumulator(): TokenAccumulator {
369 let totalInputTokens = 0;
370 let totalOutputTokens = 0;
371 let imageTokensTotal = 0;
372 let screenshotCount = 0;
373 let toolCallCount = 0;
374
375 return {
376 addImageCall(usage: TokenUsage, imageTokens: number): void {
377 totalInputTokens += usage.inputTokens;
378 totalOutputTokens += usage.outputTokens;
379 // Use the calculated image tokens (from width * height / 750)
380 imageTokensTotal += imageTokens;
381 },
382
383 addTextCall(usage: TokenUsage): void {
384 totalInputTokens += usage.inputTokens;
385 totalOutputTokens += usage.outputTokens;
386 },
387
388 incrementScreenshots(): void {
389 screenshotCount++;
390 },
391
392 incrementToolCalls(count = 1): void {
393 toolCallCount += count;
394 },
395
396 getResult(approach: string): BenchmarkResult {
397 return {
398 approach,
399 totalInputTokens,
400 totalOutputTokens,
401 totalTokens: totalInputTokens + totalOutputTokens,
402 imageTokens: imageTokensTotal,
403 screenshotsTaken: screenshotCount,
404 toolCallCount: toolCallCount > 0 ? toolCallCount : undefined,
405 };
406 },
407 };
408}
409
410/**
411 * Analyzes a screenshot using Claude and returns token usage.

Callers 4

runScreenshotApproachFunction · 0.85
runWebMCPApproachFunction · 0.85
runScreenshotApproachFunction · 0.85
runWebMCPApproachFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected