taffy icon indicating copy to clipboard operation
taffy copied to clipboard

Add Yoga benchmarks

Open TimJentzsch opened this issue 3 years ago • 3 comments

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

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_layout take a size? Is that the two Yoga.UNDEFINED are 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 the inc stuff?

TimJentzsch avatar Jun 16 '22 15:06 TimJentzsch

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.

nicoburns avatar Jul 29 '22 16:07 nicoburns

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.

nicoburns avatar Jul 29 '22 16:07 nicoburns

Right; perhaps we should just be calling yoga on our benchmarks?

alice-i-cecile avatar Jul 29 '22 16:07 alice-i-cecile

Closing: this is going to be a massive headache to rebase.

alice-i-cecile avatar Nov 23 '22 20:11 alice-i-cecile

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.

nicoburns avatar Nov 23 '22 20:11 nicoburns

(with the caveat the we don't yet have a way to benchmark yoga itself in tree)

nicoburns avatar Nov 23 '22 20:11 nicoburns