gerich-home / it-depends

Lightweight dependency tracking library for JavaScript
http://it-depends-js.github.io/
Other
1 stars 2 forks source link

itDepends vs Knockout Performance #26

Closed VanDalkvist closed 8 years ago

VanDalkvist commented 8 years ago

I created comparing tests with knockout. Only for observables for now. - http://jsperf.com/knockout-vs-itdepends/5 . Writing new values to observables without subscribers works fast (check here http://jsperf.com/knockout-vs-itdepends/7). Much much better then knockout observable. But only with one subscriber it works a bit slower.

Performance is being reduced during increasing number of subscribers. - http://jsperf.com/knockout-vs-itdepends/6

gerich-home commented 8 years ago

performance tests are added to build: https://ci.appveyor.com/project/gerich-home/it-depends/build/1.0.156

gerich-home commented 8 years ago

Some performance improvements were added to master. Better performance comparison tests are in progress.

Subscribers are stored as a linked list to allow both fast enable and disable subscription operations.

Subscriptions are stored for individual observable now, so change to unrelated observable is significantly faster now.

gerich-home commented 8 years ago

Here are the results of running performance tests locally on my machine:

'subscribe to computed with 1000 subscribers and unsubscribe them'
  1.05x slower
'subscribe to computed with 1 subscribers and unsubscribe them'
  1.40x slower
'subscribe to computed with 3 subscribers and unsubscribe them'
  1.14x slower
'subscribe to computed with 500 subscribers and unsubscribe them'
  1.01x faster
'computed updated 1000 times with 1000 subscribers'
  2.09x faster
'computed updated 1000 times with 1 subscribers'
  2.73x faster
'computed updated 1000 times with 500 subscribers'
  2.62x faster
'computed updated 1 times with 1000 subscribers'
  10.05x faster
'computed updated 1 times with 1 subscribers'
  10.42x faster
'computed updated 1 times with 500 subscribers'
  10.05x faster
'computed updated 3 times with 1000 subscribers'
  2.20x faster
'computed updated 3 times with 1 subscribers'
  1.50x faster
'computed updated 3 times with 500 subscribers'
  2.22x faster
'computed updated 50 times with 1000 subscribers'
  2.15x faster
'computed updated 50 times with 1 subscribers'
  1.83x faster
'computed updated 50 times with 500 subscribers'
  2.29x faster
'read observable 1000 times'
  2.43x faster
'read observable 100 times'
  2.03x faster
'read observable 1 times'
  1.92x faster
'subscribe to observable with 1000 subscribers and unsubscribe them'
  1.09x slower
'subscribe to observable with 1 subscribers and unsubscribe them'
  1.30x slower
'subscribe to observable with 3 subscribers and unsubscribe them'
  1.19x slower
'subscribe to observable with 500 subscribers and unsubscribe them'
  1.09x slower
'write observable 1000 times with 1 subscribers'
  12.82x faster
'write observable 1000 times with 3 subscribers'
  8.28x faster
'write observable 1000 times with 50 subscribers'
  2.62x faster
'write observable 1 times with 1000 subscribers'
  9.91x faster
'write observable 1 times with 1 subscribers'
  10.32x faster
'write observable 3 times with 1000 subscribers'
  1.83x faster
'write observable 50 times with 1000 subscribers'
  1.87x faster

As can be seen the difference on slow tests is not significant (up to 1.4 times), but on fast ones we have up to 12 times performance boost comparing to knockout.

AppVeyor yields quite a different results and needs further investigation (see #37).

For local run I have set the treshold for itDepends to be slower no more then at 1.5 times.

For now I consider the original performance issue resolved as I have the following results:

'write observable 1000 times with 1 subscribers'
  12.82x faster
'write observable 1000 times with 3 subscribers'
  8.28x faster
'write observable 1000 times with 50 subscribers'
  2.62x faster
'write observable 1 times with 1000 subscribers'
  9.91x faster
'write observable 1 times with 1 subscribers'
  10.32x faster
'write observable 3 times with 1000 subscribers'
  1.83x faster
'write observable 50 times with 1000 subscribers'
  1.87x faster
VanDalkvist commented 8 years ago

Great Job!

gerich-home commented 8 years ago

Thanks! :) However I found one intesting edge case. See it here: #41