v148 · AI · JavaScript

Quality Control Panel

Benchmark the Language Detector API against a heuristic fallback on 10 diverse text samples. See detection latency, confidence scores, and whether the on-device model is available — all in one panel.

Avg latency (ms)
Correct detections
Inference mode
Benchmark
checking…
// Benchmarking the Language Detector API async function benchmark(texts) { const detector = await LanguageDetector.create({ expectedInputLanguages: texts.map(t => t.expected) }); const results = []; for (const { text, expected } of texts) { const t0 = performance.now(); const [top] = await detector.detect(text); const latency = performance.now() - t0; results.push({ detected: top.detectedLanguage, confidence: top.confidence, correct: top.detectedLanguage === expected, latencyMs: latency.toFixed(1), }); } return results; }

see also

references

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗