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

bugfix: performance.now function should return MS instead of nano #428

Merged
merged 2 commits into from
Jul 10, 2022

Conversation

Pruxis
Copy link
Contributor

@Pruxis Pruxis commented Jul 8, 2022

No description provided.

Copy link
Contributor Author

@Pruxis Pruxis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure if correct but I think this solves
https://github.com/Jarred-Sumner/bun/issues/413

Comment on lines 1499 to 1500
double result = time / 1000000000000000.0;
return JSValue::encode(jsNumber(time));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are still returning the time variable. Please calculate double result = time / 1000000.0; and change jsNumber(time) to jsNumber(result)

Copy link
Contributor Author

@Pruxis Pruxis Jul 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I overlooked that, the added 0's are incorrect and should be time / 1_000_000.0 I suppose

@afrokick
Copy link

afrokick commented Jul 9, 2022

Maybe should add a test like expect(Math.abs(performance.now() - Date.now())).toBeCloseTo(0, 3);?

https://github.com/Jarred-Sumner/bun/blob/main/test/bun.js/performance.test.js

@Jarred-Sumner Jarred-Sumner merged commit 92225fa into oven-sh:main Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants