From: Klotz, L. <Lei...@xe...> - 2010-03-08 19:52:05
|
My test was for significantly fewer than 200 checkboxes, which is probably why I didn't see the difference in clock time. ________________________________ From: Javier Díaz [mailto:jd...@ge...] Sent: Monday, March 08, 2010 7:48 AM To: Tambet Matiisen Cc: Klotz, Leigh; xsl...@li... Subject: Re: [Xsltforms-support] xsltforms Performance Hello, We have modified all the for's acceding to the length property of an array as described in the following page: http://www.erichynds.com/javascript/javascript-loop-performance-caching-the-length-property-of-an-array/ Attached I send you all the changes we have done (although the line numbers may vary from official version, we have change some lines). With these changes, xsltforms works better when having lots of instance data. In our worst case, we had a page that in explorer didn't managed to load (a dialog to abort the script appeared because it lasted too long), while with the modification now it loads ok (unfortunately in continues to be a bit slow). I hope it may be useful for anybody. Best Regards, Javier Tambet Matiisen escribió: I just did a few tests with my case. function selectAll(form, regexp, checked) { var elements = form.elements; var elements_length = elements.length; for(var i = 0; i < elements_length; i++) { var element = elements[i]; if (element.type == 'checkbox' && element.name.search(regexp) != -1) { element.checked = checked; } } } I had a form with 200 checkboxes. for(var i = 0; i < elements_length; i++) - took ~1s to check all for(var i = 0; i < elements.length; i++) - took ~2s to check all for(var i = 0; i < form.elements.length; i++) - took ~3s to check all It seems that accessing properties (maybe only form.elements?) is slow in IE(8). All cases worked almost instantaneously in FF(3.5). Tambet Klotz, Leigh wrote: I tried this just now; it was tedious but doable. I didn't bother for strings. Some loops affect the list length and need to be left alone. I didn't get it 100% right and get the occasional JS error; care must be taken! I tried a sample application and didn't see a measureable clock-time performance improvement in IE8. There are some areas where performance is poor compared to other FF3.6 (four seconds vs instantaneous) but this didn't fix it I'm willing to believe that this fixes problems I just didn't happen encounter, but it doesn't fix one I did encounter. Leigh. ________________________________ From: Tambet Matiisen [mailto:tam...@gm...] Sent: Wednesday, January 27, 2010 12:30 AM To: xsl...@li... Subject: Re: [Xsltforms-support] xsltforms Performance Christopher Dedels wrote: Profiling tools report at least 13 seconds in IE 8 (2.5 seconds in FF/Chrome) to "tab" from one field to the next, regardless of whether the data in the field was changed. As you can expect, this is not acceptable for my users. I've noticed, that IE calculates .length property of arrays by counting all array elements. This makes such cycles especially slow: for (var i = 0; i < frm.elements.length; i++) This can be easily fixed by assigning length to a variable: var elements_length = frm.elements.length; for (var i = 0; i < elements_length; i++) You could search XSLTForms javascript code for ".length" and try if this fix makes it better. Tambet ________________________________ ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ________________________________ _______________________________________________ Xsltforms-support mailing list Xsl...@li... https://lists.sourceforge.net/lists/listinfo/xsltforms-support |