Skip to content

Conversation

@HalidOdat
Copy link
Member

Adds implementation of the W3C High Resolution Time API's performance.now() method and performance.timeOrigin getter property.

Some benchmarks use this if available, which hopefully will remove the very big fluctuations in performance measurement.

@github-actions
Copy link

github-actions bot commented Nov 30, 2025

Test262 conformance changes

Test result main count PR count difference
Total 52,598 52,598 0
Passed 49,385 49,385 0
Ignored 2,134 2,134 0
Failed 1,079 1,079 0
Panics 0 0 0
Conformance 93.89% 93.89% 0.00%

@codecov
Copy link

codecov bot commented Nov 30, 2025

Codecov Report

❌ Patch coverage is 68.42105% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.35%. Comparing base (6ddc2b4) to head (cb87a90).
⚠️ Report is 617 commits behind head on main.

Files with missing lines Patch % Lines
core/runtime/src/performance/mod.rs 74.28% 9 Missing ⚠️
core/runtime/src/extensions.rs 0.00% 2 Missing ⚠️
cli/src/main.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #4551       +/-   ##
===========================================
+ Coverage   47.24%   57.35%   +10.11%     
===========================================
  Files         476      505       +29     
  Lines       46892    57964    +11072     
===========================================
+ Hits        22154    33248    +11094     
+ Misses      24738    24716       -22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@HalidOdat HalidOdat force-pushed the feature/performance-now branch from 9da3354 to ebc1e14 Compare December 18, 2025 00:37
Adds implementation of the W3C High Resolution Time API's performance.now()
method and performance.timeOrigin getter property.

Spec: https://w3c.github.io/hr-time/
@HalidOdat HalidOdat force-pushed the feature/performance-now branch from ebc1e14 to cb87a90 Compare December 18, 2025 00:37
@HalidOdat HalidOdat marked this pull request as ready for review December 18, 2025 00:38
@HalidOdat HalidOdat requested a review from a team December 18, 2025 00:38
@HalidOdat
Copy link
Member Author

Ideally this should inherit from EventTarget (not implemented) have some work on that in a separate PR.

time_origin: JsInstant,
}

impl Performance {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason you don't use the boa_class proc macro here? It would significantly reduce the code.

@hansl
Copy link
Contributor

hansl commented Dec 18, 2025

Ideally this should inherit from EventTarget

@HalidOdat I was starting work on class inheritance with that specifically in mind, but hit a road block and inheritance in Rust currently is broken. Do you have pointers to help?

@HalidOdat
Copy link
Member Author

HalidOdat commented Dec 18, 2025

Oh didn't know you where working on that... the way I implemented it was on the boa_class by adding a #[boa(inherit)] that can be added to a method that takes context and returns JsResult<JsObject> (returns the prototype to be inherited) (see here).

Since we can attach custom host fields on the realm, I was thinking of adding an RuntimeIntrinsics (like we do on boa_engine) and that can be accessed (through the context) and we can get the prototype. This avoids having to do globalThis gets.

@hansl
Copy link
Contributor

hansl commented Dec 18, 2025

Having the inherit being an attribute on the class is more natural and closer to what JavaScript really does. Here's my PR: https://github.com/boa-dev/boa/pull/4431/changes#diff-37970e7d817d4316a093bb967d74ff7e26d9c6c01d93f5a79d3d195ba9f6155bR389

Also this allows for JS classes to inherit Rust classes which inherit JS classes, etc.

@hansl
Copy link
Contributor

hansl commented Dec 18, 2025

I think the main blocker is that Rust's JsObject prototype stuff is broken and doesn't work. I could get it to work for static methods but not instance, for some reason. We also need to figure out a way to call super from the base class (I think I had JsSuper as an argument in that PR).

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.

2 participants