Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different output in console.timeEnd between engines #15175

Closed
sant123 opened this issue Jul 12, 2022 · 2 comments · Fixed by #25723
Closed

Different output in console.timeEnd between engines #15175

sant123 opened this issue Jul 12, 2022 · 2 comments · Fixed by #25723
Labels
ext/console Related to the ext/console crate suggestion suggestions for new features (yet to be agreed)

Comments

@sant123
Copy link

sant123 commented Jul 12, 2022

let obj = {}, map = new Map(), n = 1000000;

for (let i = 0; i < n; i++) {
  obj[i] = i;
  map.set(i, i);
}

let result;
console.time("Object");
result = obj.hasOwnProperty("999999");
console.timeEnd("Object");

console.time("Map");
result = map.has(999999);
console.timeEnd("Map");

This is what Deno prints:
image

This is what Node.js prints:
image

This is what Google Chrome prints:
image

What I see is Node.js and Google Chrome print the result in decimal but Deno is rounding the number. I'm curious if this is expected?

Thanks.

Source - https://bretcameron.medium.com/how-javascript-maps-can-make-your-code-faster-90f56bf61d9d

@kitsonk kitsonk added suggestion suggestions for new features (yet to be agreed) ext/console Related to the ext/console crate labels Jul 12, 2022
@kitsonk
Copy link
Contributor

kitsonk commented Jul 12, 2022

It should be noted that high resolution time is not available by default in Deno due to security issues and requires a permission flag. But console should log the partial ms if available, IMO.

@comunidadio
Copy link

Even with -A option, and with performance.now() returning with precision, console.time is still limited to millisecond precision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ext/console Related to the ext/console crate suggestion suggestions for new features (yet to be agreed)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants