import { fetch } from "https://esm.town/v/std/fetch";
export const measureValTownE2e = (async () => {
const count = 5;
let evalTimes = [];
for (let i = 0; i < count; i++) {
let start = Date.now();
await fetch("https://api.val.town/eval/(()=%3E1+1)()");
evalTimes.push(Date.now() - start);
}
console.log(
`average e2e eval time: ${
(evalTimes.reduce((a, b) => a + b, 0) / count).toFixed(0)
}ms (fastest was ${
evalTimes
.sort((a, b) => a - b)[0]
.toFixed(0)
}ms)`,
);
let userFuncTimes = [];
for (let i = 0; i < count; i++) {
let start = Date.now();
await fetch("https://api.val.town/eval/@healeycodes.addOnes()");
userFuncTimes.push(Date.now() - start);
}
console.log(
`average e2e user function time: ${
(userFuncTimes.reduce((a, b) => a + b, 0) / count).toFixed(0)
}ms (fastest was ${
userFuncTimes
.sort((a, b) => a - b)[0]
.toFixed(0)
}ms)`,
);
})();