boa icon indicating copy to clipboard operation
boa copied to clipboard

Implement Performance.now() and Performance.timeOrigin

Open HalidOdat opened this issue 3 months ago • 2 comments

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.

HalidOdat avatar Nov 30 '25 18:11 HalidOdat

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%

github-actions[bot] avatar Nov 30 '25 18:11 github-actions[bot]

Codecov Report

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

Files with missing lines Patch % Lines
core/runtime/src/performance/mod.rs 74.28% 9 Missing :warning:
core/runtime/src/extensions.rs 0.00% 2 Missing :warning:
cli/src/main.rs 0.00% 1 Missing :warning:
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     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov[bot] avatar Nov 30 '25 18:11 codecov[bot]

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

HalidOdat avatar Dec 18 '25 00:12 HalidOdat

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?

hansl avatar Dec 18 '25 00:12 hansl

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.

HalidOdat avatar Dec 18 '25 18:12 HalidOdat

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 avatar Dec 18 '25 19:12 hansl

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).

hansl avatar Dec 18 '25 20:12 hansl