perf(intl): add benchmarks for Collator, ListFormat, PluralRules, Segmenter, DateTimeFormat and NumberFormat#4898
Conversation
Test262 conformance changes
Fixed tests (2):Broken tests (157):Tested main commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4898 +/- ##
===========================================
+ Coverage 47.24% 58.42% +11.18%
===========================================
Files 476 559 +83
Lines 46892 61459 +14567
===========================================
+ Hits 22154 35910 +13756
- Misses 24738 25549 +811 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
you probably need to update benches/full.rs, otherwise the benchmarks are not registered by Criterion |
|
@jedel1043 Thanks for the note! but the Intl benchmarks are auto-discovered by scripts.rs via
Is this the correct approach, or would you prefer they be integrated |
|
Oh sorry! I thought you were touching the |
|
@jedel1043 Thanks for confirming! I will proceed with this then. Do you have any suggestions to add on this benchmarks ? |
…cross multiple locales
not yet implemented
ba0fc3f to
db933a1
Compare
|
@jedel1043 Could you take a look at this when you get a chance? I'm in the plan of extending the benchmark suite for the remaining Intl APIs then apply the same caching strategy to NumberFormat as I did for DateTimeFormat after verifying with benchmarks. |
|
Summary of this PR, @jedel1043 after reviewing the source for all Intl APIs, DateTimeFormat was the only one reconstructing ICU4X formatter on every format() call. The fix caches the DateTimeFormatter on the struct, created once during construction and cloned in the format closure resulting in around 42% improvement across format and construction benchmarks. |
|
Thanks! |
|
hmmm i think with this pr, now |
|
Oh whoops we need to add that feature to the crate in |
|
@zhuzhu81998 Thanks for pointing this out. @jedel1043 i'm fixing this right away! |
After #4898, running cargo bench -p boa_benches without --features boa_engine/intl_bundled panics with "Intl is not defined" since the Intl benchmark scripts require the intl feature to be enabled. This adds intl_bundled as a default feature for boa_benches so `cargo bench -p boa_benches` works without any panics message: "Intl is not defined".


As suggested in #4790, adds performance benchmarks for Intl APIs (
Intl.DateTimeFormat, Intl.NumberFormat) to establish baselines for future optimization work.Note
The
format()benchmark uses a fixed date (new Date(2024, 0, 1)) for deterministic results.Cache Optimization
Also caches the DateTimeFormatter on the DateTimeFormat struct instead of recreating it on every format() call. Previously, every format() invocation loaded locale data from the provider from scratch.