luwes / js-diff-benchmark

Simple benchmark for testing your DOM diffing algorithm.
67 stars 5 forks source link

Consider adding `random` shuffle in the mix #2

Closed WebReflection closed 4 years ago

WebReflection commented 4 years ago

Another interesting test to put in the mix:

diff(
    parent,
    parent.childNodes,
    parent.childNodes.sort(() => Math.random() - Math.random()),
    get,
    parent.lastElementChild
  );

Warning

snabdom here fails 1 out of 3 times so that tests should likely be put in try/catch and warn in red the test broke/didn't work.

You can give it a try with 1000 rows already, launch it few times and see snabdom fall.

I might file an issue in there though ... or maybe they know already.

luwes commented 4 years ago

thanks for checking! the snabbdom script used here might not be 1 to 1 with the real thing. I will see if I can find the issue later.

tomByrer commented 4 years ago

The lack of randomness in all speed tests irks me. Thanks for requesting & looking into it guys!

luwes commented 4 years ago

Array.sort() is mutating right? is that okay in this case

luwes commented 4 years ago

oh yea that's a slice behind the scenes 😅