Add Yoga benchmarks
Objective
Fixes #166.
This PR aims to implement the Yoga benchmarks to serve as a comparison point for other libraries.
- [ ] Stack with flex
- [ ] Align stretch in undefined axis
- [ ] Nested flex
- [x] Huge nested layout
Context
- The corresponding Yoga benchmarks: https://github.com/facebook/yoga/blob/578d197dd6652225b46af090c0b46471dc887361/javascript/tests/Benchmarks/YGBenchmark.js
Feedback wanted
- Is my implementation faithful to Yoga's original benchmarks?
- What does this do? https://github.com/facebook/yoga/blob/578d197dd6652225b46af090c0b46471dc887361/javascript/tests/Benchmarks/YGBenchmark.js#L21 Do we have something equivalent?
- Why does
compute_layouttake asize? Is that the twoYoga.UNDEFINEDare for or is that not equivalent to Yoga? - Are our default values the same as in Yoga? Especially the flex direction might be different, as they specify it explicitly in some styles and not in others.
- What does
child.setMeasureFunc(measureCounter.inc);do exactly, do we have something equivalent? What is theincstuff?
getMeasureCounter is defined here: https://github.com/facebook/yoga/blob/578d197dd6652225b46af090c0b46471dc887361/javascript/tests/tools.js
It seems to be part of their test harness. And looks to be counting how many times the measure function is called. I imagine this is relevant because measure func calls are typically expensive in real systems (may involved doing text layout, etc), and caching could potentially reduce the number of times it is called.
It seems to me that if we want to compare with other libraries, we should directly include them in our benchmarks (perhaps via yoga-rs?) rather than trying to match our test harness to theirs exactly.
Right; perhaps we should just be calling yoga on our benchmarks?
Closing: this is going to be a massive headache to rebase.
This is actually now at least partially implemented in benches/big_tree.rs. We are running several variants of yoga's "huge nested layout" with various node counts, including 10,000 which is what they benchmark. They have a couple of other benchmarks, but they seem too small to be interesting to me.
(with the caveat the we don't yet have a way to benchmark yoga itself in tree)