Files
sousa-gecko/accessible/tests/browser/performance
Morgan Rae Reschenberg b63ae10500 Bug 2046009: Add performance tests for bounds, display:contents bounds r=perftest-reviewers,mozperftest-reviewers,Jamie,sparky
This patch adds two performance tests to measure the cost of the naive solution to bounds computation for display:contents accessibles against our "normal" bounds ocmputation. Here's some data from a recent try run that shows how this algorithm compares to (a) our basic bounds algorithm and (b) other hot paths in our perf test suite.

A summary, to save some time digging into the data:

As you might expect, a single `getBounds()` on a `display:contents` container with 10k children costs more than any other tracked per-op cost in the suite. The cost for this operation is ~3–5 milliseconds. The cost for 100 of these queries (the entire test run) is ~300-500 milliseconds.

I think this is still worth shipping as a stop gap for the kind of navigation issues VoiceOver experiences as a result. I ALSO think we should dig in further and come up with a more performant situation.

Separately: Linux is an outlier on `browser_addManyNodes.js`... what's going on there...

Try push: <https://treeherder.mozilla.org/jobs?repo=try&landoInstance=lando-prod-2025&landoCommitID=57011>

| Test | linux2404-64-shippable | mac1015-64-shippable-qr | win11-24h2-shippable | win11-24h2-hw-ref-shippable |
|---|---:|---:|---:|---:|
| `browser_bounds.js` | 0.472 ms | 0.274 ms | 0.289 ms | 0.425 ms |
| `browser_displayContentsBounds.js` | 477.690 ms | 554.363 ms | 344.961 ms | 346.721 ms |

| Test                               | linux2404-64-shippable | mac1015-64-shippable-qr | win11-24h2-shippable | win11-24h2-hw-ref-shippable |
| ---------------------------------- | ---------------------: | ----------------------: | -------------------: | --------------------------: |
| `browser_bounds.js`                |                4.72 µs |                 2.74 µs |              2.89 µs |                     4.25 µs |
| `browser_displayContentsBounds.js` |             4776.90 µs |              5543.63 µs |           3449.61 µs |                  3467.21 µs |

Each perftest runs a hot loop of N operations and reports the total wall time. Dividing
total time by N gives an approximate time-per-call cost.

| Test | N (ops) | linux | mac CI | win-main | win-ref |
|---|---:|---:|---:|---:|---:|
| `browser_addManyIds.js` (setAttribute id) | 10,000 | 5.76 µs | 6.65 µs | 3.58 µs | 3.28 µs |
| `browser_addManyNodes.js` (append child div) | 100,000 | 246.61 µs | 38.12 µs | 23.45 µs | 23.63 µs |
| `browser_bounds.js` (`getBounds` on framed) | 100 | 4.72 µs | 2.74 µs | 2.89 µs | 4.25 µs |
| `browser_displayContentsBounds.js` (`getBounds` on display:contents) | 100 | 4,776.90 µs | 5,543.63 µs | 3,449.61 µs | 3,467.21 µs |
| `browser_implicitRoleARIAExpanded.js` (append element w/ implicit role) | 10,000 | 22.06 µs | 20.50 µs | 11.40 µs | 13.19 µs |
| `browser_reflowPseudoelements.js` (reflow pseudoelement) | 15,000 | 37.06 µs | 46.76 µs | 25.72 µs | 30.65 µs |
| `browser_removeManySpellingErrors.js` (remove spell error) | 500 | 168.26 µs | 192.78 µs | 90.61 µs | 116.92 µs |

Differential Revision: https://phabricator.services.mozilla.com/D306267
2026-06-18 20:08:17 +00:00
..
…