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
- Confidence Meter — live confidence bars
- Language Sniffer — interactive detection
- Local Triage Workflow — realistic app flow
- Safety Harness — edge case test suite
references
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗