On Jun 21, 2013, at 11:26 AM, Dr. Hawkins wrote: > On Fri, Jun 21, 2013 at 2:33 AM, Mark Wilcox <m_p_wil...@yahoo.co.uk> wrote: >> A good example from this thread is having four different versions of the >> same function with >> tiny variations at the beginning. > > For that matter . . . does anyone really know the timing comparisons > for LiveCode. Say, for parsing a constant "abc", pulling it from a > variable (ltrs), and an array? (which was all I was optimizing away, > really, fixed for the price of a four way switch setting the > variable). > > Or if I'm doing or not doing something with an array element based on > that element, is > > if ary[why][el] > 12 then > put gizmo(ary[why][el]) into widget > end if > > better than > > put ary[why][el] into tstVal > if tstVal > 12 then > put gizmo(tstVal) into widget > end if
Well, here's a benchmark for using an intermediate array, comparing these two scripts: put 7 into tArray[1][2][3] put 127 into tArray[1][2][4] put tArray[1][2] into tempArray if tArray[1][2][3] > 6 then put tArray[1][2][4] into tWidget end if vs. put 7 into tArray[1][2][3] put 127 into tArray[1][2][4] put tArray[1][2] into tempArray if tempArray[3] > 6 then put tempArray[4] into tWidget end if Running the comparison on my old MacBook Core 2 Duo within a high-n repeat loop I get script 1: 2.177881 seconds script 2: 1.962642 seconds so the intermediate shallow array saves some time, presumably increasingly more with deeper arrays. OTOH, long variable names do nothing to shave clock cycles at runtime, I think that whatever the variable names it gets compiled to the same code. There is an old stack by Richard Gaskin, 4W_RevBench, that I have usually used for benchmarking but I just pulled it out and it is now acting very weird for me since I moved to LC 5.5, so I rolled my own handler for this test. -- Peter Peter M. Brigham pmb...@gmail.com http://home.comcast.net/~pmbrig _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode