Re: Fast/slow code example (was: Re: compileIt for revolution?)
On Jun 26, 2005, at 4:01 PM, Jeanne A. E. DeVoto wrote: It should be mentioned in the docs. (And probably is and I don't know where.) In the dictionary for the "repeat" control structure. ;-) I thought it would be, but when I skimmed over that, I missed it. Dar ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Fast/slow code example (was: Re: compileIt for revolution?)
At 1:09 PM -0600 6/24/2005, Dar Scott wrote: On Jun 24, 2005, at 12:42 PM, Jim Bufalini wrote: However, the "repeat with i =" form being slower than the "repeat for each" was news to me! It should be mentioned in the docs. (And probably is and I don't know where.) In the dictionary for the "repeat" control structure. ;-) "Use the for each form if you want to perform an action on each chunk in a container. This form is much faster than the with countVariable = startValue to endValue form when looping through the chunks of a container." (It doesn't go into detail about why this is so, though, and that would be interesting and perhaps useful information to add.) There also used to be some mentions of this in the cookbook, although the cookbook seems to have gone away. -- jeanne a. e. devoto ~ [EMAIL PROTECTED] http://www.jaedworks.com ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Fast/slow code example (was: Re: compileIt for revolution?)
On Jun 24, 2005, at 12:42 PM, Jim Bufalini wrote: However, the "repeat with i =" form being slower than the "repeat for each" was news to me! Upon reflection, you might have wondered about that. The key is that the first uses 'line i of x' in the loop. The length of time to get this value increases with i. Normally, values are simply sequences of characters and values with multiple lines are simply values that contain some line-delimiter characters (coded the same as ASCII LF). Though it is possible that some internal optimization breaks these up into structured data or a line-index table is cached, it is reasonable to suspect that this is not the case. If there is no optimization to finding line n, then all characters form the start of the string to line n must be searched. It is possible that some compiler optimization would look for line n in loops and convert, but our first assumption should be that it probably doesn't. We might assume that 'for each' does not have this limitation. We might assume that 'for each' keeps one or more hidden character indexes in managing the loop. Given such suspicions we might try some timing or ask on the list. This does not currently apply to characters; 'char n of s' executes in constant time. Even so... We all are sometimes surprised by things that should jump out. I am. It should be mentioned in the docs. (And probably is and I don't know where.) Dar -- ** DSC (Dar Scott Consulting & Dar's Lab) http://www.swcp.com/dsc/ Programming and software ** ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
RE: Fast/slow code example (was: Re: compileIt for revolution?)
Eric, For someone moving from other languages (like I am) to Transcript, I believe three of the four errors you point out in your example should be obvious and the same in all languages. Those are: 1. Repeatedly accessing the same data structure (field) instead of first putting it into a variable. 2. Repeatedly updating the screen on a background process. 3. Repeatedly setting a property that only needs to be set once. However, the "repeat with i =" form being slower than the "repeat for each" was news to me! There is nothing in the documentation, that I can find, that addresses the most efficient way, from the perspective of the engine, to write a control structure. Apparently, this is particularly true of the repeat structure. Is it also true for say the if..then structure? Is it more efficient to put your conditions into variables and then use the variables as conditions of the if...then? These are the kinds of things a newbie (like myself) would greatly appreciate being documented. This is to say, if there are two or more ways to write the same statement (as with the repeat example), then if someone knows one works faster than the rest, because of their knowledge of the inner workings of the engine, then this would be valuable to document or post. This might cut down the 300 pages. :) Jim -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Eric Chatonet Sent: Thursday, June 23, 2005 11:02 PM To: How to use Revolution Subject: Fast/slow code example (was: Re: compileIt for revolution?) Hi Christian, Le 24 juin 05 à 10:21, Langers Christian a écrit : > Could you, please, give us (newbies/intermediate scriptesr) some > examples of fast/slow script code ? They would be too many :-) In fact, the problem is often more an architecture issue than a simple code issue. But here is one tiny trivial example among thousands to give you some clues: on CheckList repeat with i = 1 to the number of lines of fld "List1" set the itemDel to tab put item 2 of line i of fld "List1" & cr after fld "List2" end repeat end CheckList Main errors in the above 4 lines are: manipulate data directly from a field (a lot of work for the engine) use the "repeat with i" form slower than the "repeat for each" form (especially noticeable with long lists) force a screen redraw at each repetition (that's the must for slowing down) set the itemDel unnecessarily at each repetition The result with 1000 lines: more than 13 seconds... Better code: on CheckList local tList, tLine, tNewList - put fld "List1" into tList set the itemDel to tab repeat for each line tLine in tList put item 2 of tLine & cr after tNewList end repeat put tNewList into fld "List2" end CheckList manipulate data into a variable use the "repeat for each" form use one screen redraw only set the itemDel only when needed The result with 1000 lines: less than 20 milliseconds! 650 times faster... Keep in mind that to answer correctly your request, this post should be a 300 pages book :-) May be Dan wrote it? Best Regards from Paris, Eric Chatonet. So Smart Software For institutions, companies and associations Built-to-order applications: management, multimedia, internet, etc. Windows, Mac OS and Linux... With the French touch Free plugins and tutorials on my website Web sitehttp://www.sosmartsoftware.com/ Email[EMAIL PROTECTED]/ Phone33 (0)1 43 31 77 62 Mobile33 (0)6 20 74 50 86 ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Fast/slow code example (was: Re: compileIt for revolution?)
Well, _my_ understanding of the online scripting conferences is that they are intended towards newbies; thus they are more about basic functionality and how-to use Rev as opposed to code optimization. Am I wrong Jacque? Judy On Fri, 24 Jun 2005, Langers Christian wrote: > Perhaps, I will find more infos in the online scripting conferences ? ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Fast/slow code example (was: Re: compileIt for revolution?)
I think such a book should make a distinction between slow/fast code in general, and specific Transcript tricks to speed up (or to avoid slowing down) your code. Regarding the later, you can check the following url : http://www.sonsothunder.com/index2.htm?http://www.sonsothunder.com/devres/revolution/revolution.htm under "scripting tricks". By following some advices in these 3 papers, I've been able to speed up some script by a factor of 5 to 7, which is greatly apreciated when one has to run heavy tasks online with Rev cgi... JB > Thanks for your answer, > > >> Keep in mind that to answer correctly your request, this post > >> should be a 300 pages book :-) > > Wouldn't it be time to write that book ? ;-) > > I see a little bit better how to optimize my scripts... > > Perhaps, I will find more infos in the online scripting conferences ? > ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Fast/slow code example (was: Re: compileIt for revolution?)
Thanks for your answer, Keep in mind that to answer correctly your request, this post should be a 300 pages book :-) Wouldn't it be time to write that book ? ;-) I see a little bit better how to optimize my scripts... Perhaps, I will find more infos in the online scripting conferences ? Christian from Luxembourg ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Fast/slow code example (was: Re: compileIt for revolution?)
Hi Christian, Le 24 juin 05 à 10:21, Langers Christian a écrit : Could you, please, give us (newbies/intermediate scriptesr) some examples of fast/slow script code ? They would be too many :-) In fact, the problem is often more an architecture issue than a simple code issue. But here is one tiny trivial example among thousands to give you some clues: on CheckList repeat with i = 1 to the number of lines of fld "List1" set the itemDel to tab put item 2 of line i of fld "List1" & cr after fld "List2" end repeat end CheckList Main errors in the above 4 lines are: manipulate data directly from a field (a lot of work for the engine) use the "repeat with i" form slower than the "repeat for each" form (especially noticeable with long lists) force a screen redraw at each repetition (that's the must for slowing down) set the itemDel unnecessarily at each repetition The result with 1000 lines: more than 13 seconds... Better code: on CheckList local tList, tLine, tNewList - put fld "List1" into tList set the itemDel to tab repeat for each line tLine in tList put item 2 of tLine & cr after tNewList end repeat put tNewList into fld "List2" end CheckList manipulate data into a variable use the "repeat for each" form use one screen redraw only set the itemDel only when needed The result with 1000 lines: less than 20 milliseconds! 650 times faster... Keep in mind that to answer correctly your request, this post should be a 300 pages book :-) May be Dan wrote it? Best Regards from Paris, Eric Chatonet. So Smart Software For institutions, companies and associations Built-to-order applications: management, multimedia, internet, etc. Windows, Mac OS and Linux... With the French touch Free plugins and tutorials on my website Web sitehttp://www.sosmartsoftware.com/ Email[EMAIL PROTECTED]/ Phone33 (0)1 43 31 77 62 Mobile33 (0)6 20 74 50 86 ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution