Bug 1956017 - add asserts to model results in perf test r=tarek

Differential Revision: https://phabricator.services.mozilla.com/D242944
This commit is contained in:
Chidam Gopal
2025-03-26 15:14:40 +00:00
parent c8e9941390
commit fc9c76fce2

View File

@@ -81,6 +81,13 @@ const runInference2 = async () => {
const numIterations = 10;
let query = "restaurants in seattle, wa";
let names = ["intent", "ner"];
// expected output from MLSuggest model
const EXPECTED_INTENT = "yelp_intent";
const EXPECTED_CITY = "seattle";
const EXPECTED_STATE = "wa";
const EXPECTED_SUBJECT = "restaurants";
let addColdStart = false;
for (let name of names) {
name = name.toUpperCase();
@@ -115,6 +122,10 @@ const runInference2 = async () => {
let memUsage = await getTotalMemoryUsage();
intent_metrics[`${TOTAL_MEMORY_USAGE}`] = memUsage;
ner_metrics[`${TOTAL_MEMORY_USAGE}`] = memUsage;
Assert.equal(res.intent, EXPECTED_INTENT);
Assert.equal(res.location.city, EXPECTED_CITY);
Assert.equal(res.location.state, EXPECTED_STATE);
Assert.equal(res.subject, EXPECTED_SUBJECT);
for (let [metricName, metricVal] of Object.entries(intent_metrics)) {
if (metricVal === null || metricVal === undefined || metricVal < 0) {
@@ -137,7 +148,7 @@ const runInference2 = async () => {
};
/**
* Tests remote ML Suggest feature
* Tests remote ML Suggest feature performance
*/
add_task(async function test_ml_suggest_feature() {
await runInference2();