-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$.observe/$.unobserve performance degradation over time #448
Comments
I found one major performance improvement in the observable code. I'm not sure if it will fix the over time degradation though.
line 174:
It turns out that when an object has many keys the for-in construct is painfully slow (at least in chrome). If you could use a length property like I did here the performance would become much better. If there are other parts of the jsviews code where you use the for-in construct to check if an object contains keys you might want to consider a dedicated length property. |
Thanks Johan, yes, I had been looking at the issue, and finally narrowed it down to that same line of code, (174) as the main culprit. (I found that just yesterday evening, so we were apparently working in parallel :) ...) I will explore optimisations on that. Also, for your "degradation over time" scenario, it seems not to be related to time, but to the fact of replacing the array I'll investigate more, if I can... |
I followed your suggestion for a length property, but using a very 'low tech' approach that requires few lines of code, and works in IE too. It is here: It does indeed radically improve performance in your scenario of doing observeAll (or equivalent) on very big arrays. I didn't manage to understand why replacing the Let me know if you have any thoughts or concerns.... |
It works like a charm. Thanks! |
Feature improvements for JsRender on Node.js: (See issue BorisMoore/jsrender#357) - File based templates for JsRender on Node.js now allow absolute paths See the updated documentation topic: https://www.jsviews.com/#node/filetmpls@htmlfile - The renderFile() method for JsRender on Node.js now allows passing of context and helpers as well as data See the new documentation topic: https://www.jsviews.com/#node/filetmpls@renderfilehlelpers Performance optimization changes: - BorisMoore/jsviews#448 $.observe/$.unobserve performance degradation over time - BorisMoore/jsviews#447 removeView performance Several bug fixes, including: - BorisMoore/jsviews#446 Observable change error, when loading jquery.observable.js before jsrender.js, and using contextual parameters and sorted {{for}} - BorisMoore/jsviews#440 linked tag property changed handler called when it shouldn't - BorisMoore/jsviews#445 jsrender.min.js.map truncated Additional small corrections or improvements to documentation and some additional unit tests...
Feature improvements for JsRender on Node.js: (See issue BorisMoore/jsrender#357) - File based templates for JsRender on Node.js now allow absolute paths See the updated documentation topic: https://www.jsviews.com/#node/filetmpls@htmlfile - The renderFile() method for JsRender on Node.js now allows passing of context and helpers as well as data See the new documentation topic: https://www.jsviews.com/#node/filetmpls@renderfilehlelpers Performance optimization changes: - #448 $.observe/$.unobserve performance degradation over time - #447 removeView performance Several bug fixes, including: - #446 Observable change error, when loading jquery.observable.js before jsrender.js, and using contextual parameters and sorted {{for}} - #440 linked tag property changed handler called when it shouldn't - #445 jsrender.min.js.map truncated Additional small corrections or improvements to documentation and some additional unit tests...
This has been fixed in new release v1.0.7 |
Please look at this fiddle
Notice how the observe/unobserve times increase for each iteration and then becomes lower again after ~15 or so iterations. The times are never as fast as the first couple of iterations.
I should say that this is not my actual data but it's a simple representation of what I'm doing.
Also the jquery version used doesn't seem to matter.
(code included below for future reference)
The text was updated successfully, but these errors were encountered: