4 ms·
I'm not sure. But FWIW I don't think more complex nesting would change anything in this regard. Those transforms essentially just avoid you having to wrap some
by fabiospampinato 4y ago
I'm not sure. But FWIW I don't think more complex nesting would change anything in this regard. Those transforms essentially just avoid you having to wrap some things in functions manually, and avoid some extra function calls. Avoiding manual wrapping is a convenience feature and those extra function calls are not really that expensive (or it wouldn't be possible for Voby to be faster than something optimized like Solid in the benchmark).
If you'd like to come up with a different sort of benchmark where you think Solid would shine I'd be happy to write an implementation of it with Voby and see what happens. Or you can just try that yourself, the API is fairly similar.
---
I should probably add that js-framework-benchmark is heavily biased toward measuring creation time actually, which is something where compile-time optimizations should shine. If you are more interested in updating things, like you would be in a rich application, Voby is actually some 20% faster than Solid at replacing rows with other rows, because it support reusing of older nodes (opt-in) (this also lowers memory pressure in some cases by the way, no need to make and gc lots of stuff in some cases). This optimization is not supported in Solid nor Svelte, and interestingly it's not a safe optimization that can be applied all the time, so it must be opt-in, but how are you supposed to tell to Solid or Svelte when it's safe to apply it if something like Voby's "template" function, which is also used for this, is abstracted away entirely from you? In some sense the transform actively goes against performance here.
- kaba0 4y agoI am absolutely not well-versed in JS framework internals, but isn’t this reuse the difference between Solid’s <For> vs <Index>?
- fabiospampinato 4y agoNo, the difference is that if you pass to Solid's <For> a signal to an array, and make a node for each of the values of that array, and then you change the signal to point to an empty array, then Solid just deletes those nodes and they eventually get garbage collected, if you then pass the signal an array containing some values then new nodes are recreated. The difference is that in Voby, if you explicitly opt into this, nodes are not deleted but kept in memory when going to an empty array, and new one are not created when going back to a non-empty array, those nodes kept in memory are repurposed. As a rule of thumb if you don't have any API for explicitly opting into recycling it's not happening, it's not a safe optimization that can be applied all the time.
- woojoo666 4y agoI guess I feel like deep complex structures are where we would see significant differences between VDOM (react) and compiled (svelte) but I might be wrong, I'm not too familiar with the internals of either framework