wilsonpage / fastdom

Eliminates layout thrashing by batching DOM measurement and mutation tasks
6.83k stars 240 forks source link

Demo 2 slower on safari 9 #69

Closed chenglou closed 8 years ago

chenglou commented 8 years ago

MBA 2014 baseline specs. "Without FastDom" takes 3-4ms while "With FastDom" takes 9-17ms.

Guess browser perf is that unpredictable...

aFarkas commented 8 years ago

@chenglou

Safari 9 is indeed extreme fast on this test. And I can't explain myself fully why they are so extreme fast. (I suspect they have found a fast path for detecting, that a layout change of one box has no effect on the layout of another box. But I'm sure this won't work always in more complex situations. Additionally it seems that a lot of rendering is happening in another thread, not the main/JS thread. It's kind of async.).

However: Fastdom works async. Between your click and actually doing the task is a time gap where the browser is idling, which might take 16.667ms. While without fastdom it is sync (without a gap). The performance measurement is also including this idl time.

For the user this time gap isn't lost/visible, because fastdom starts exactly at the point right before the browser wants to render the next frame.

So measurement is bad, not fastdom.

Until this measurement is fixed you can workaround this by increasing number of elements, so that you get a time above 60ms-100ms (2500 elements in my case) and then compare it.