๐Ÿš€ Everything is free โ€” help us improve! Submit feedback and shape the platform.
๐ŸงชTDD Challengeยทintermediateยทโฑ๏ธ 25โ€“40mยทโญ 150 XP

M-074Normalize LLM Latency Metrics

Description

Nebula Corp's monitoring dashboard shows raw latency for LLM calls, but the numbers are misleading โ€” a 5-second response generating 800 tokens looks 'slow' while a 500ms response generating 10 tokens looks 'fast'. Build a latency normalization system that calculates tokens-per-second throughput, Time to First Token (TTFT), and identifies actual performance bottlenecks by comparing normalized metrics.

Test Cases (3)

Normalizes latency
Should calculate tokens/sec for a request
Input:normalizeLatency({id:'r1',model:'gpt-4o',latencyMs:800,inputTokens:200,outputTokens:20,ttftMs:180})
Expected:CONTAINS:25
Identifies bottlenecks
Should flag slow requests as bottlenecks
Input:normalizeLatency({id:'r7',model:'gpt-4o',latencyMs:12000,inputTokens:3000,outputTokens:100,ttftMs:4500})
Expected:CONTAINS:true
Calculates percentiles
Should calculate P50 correctly
Input:percentile([100,200,300,400,500], 50)
Expected:CONTAINS:300

Related Lessons

Click Run / Check to validate your solution