Performance.now() returns the same timestamps although run at different times?

For Workes & Pages, what is the name of the domain?

https://fibonacci-precise.di-benedetto.workers.dev/

What is the issue or error you’re encountering

Performance.now() ran at different times and returned the same timestamps.

What are the steps to reproduce the issue?

Deploy a worker with following code:

var coldStart = true;
var fibonacci_precise_default = {
async fetch(request, env, ctx) {
let isCold = false;
if (coldStart) {
console.log(“This is a cold start!”);
coldStart = false;
isCold = true;
}
function fibonacci(n2) {
if (n2 <= 1)
return n2;
return fibonacci(n2 - 1) + fibonacci(n2 - 2);
}
const requestBody = await request.json();
const n = requestBody.n;
const start = performance.now();
const result = fibonacci(n);
console.log("Fibonacci result: ", result);
const end = performance.now();
const body = JSON.stringify({ start, end, isCold });
return new Response(body, {
headers: {
“content-type”: “application/json;charset=UTF-8”,
}
});
}
};
export {
fibonacci_precise_default as default
};

Call worker endpoint with payload like {“n” : “26”} .
Example response recieved:
{“start”:1727863339901,“end”:1727863339901,“isCold”:false}

This is expected, see…

3 Likes

Thanks!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.