[ANN] Help with a LiveCode Presentation/Demo
Kay C Lan
lan.kc.macmail at gmail.com
Wed Jun 5 05:53:04 EDT 2013
Monte,
Very interesting, but you've made a mistake as well. Both your code and
Peter's produce exactly the same string, there is no exponential growth.
I created the following script:
on mouseUp
-- yes it's not a million cause I couldn't wait
put 100000 into tRepeats
put the long seconds into tStart
put "Hello" into tHW
repeat tRepeats times
put tHW & "!" into tHW
end repeat
put the long seconds into tEnd
put tEnd - tStart into tTimeTaken
put "INTO took " &tTimeTaken & cr into msg
put the long seconds into tStart
put "Hello" into tWH
repeat tRepeats times
put "!" after tWH
end repeat
put the long seconds into tEnd
put tEnd - tStart into tTimeTaken
put "AFTER took " &tTimeTaken & cr after msg
if (tWH = tWH) then
put "TRUE" after msg
else
put "FALSE" after msg
end if
end mouseUp
On my machine both strings end up equal. This appears to be like 'repeat
for each' which we've all learnt is generally much faster than any other
repeat loop. For reasons I certainly can't explain, LC seems to handle 'put
after' exponentially faster than 'put into'.
As Peter cautioned, speed comparisons are fraught with comparing Apples
with Cheeses, but in this case, it made me look into V8 and I see, just
like SC and MC learnt a long time ago, a better optimised engine makes a
world of difference. It also emphasis what Richard Gaskin keeps telling us,
that if speed matters, you'll need to skin the cat a couple of different
ways to actually determine which IS the fastest LC code.
I've now amended my Google Spreadsheet to indicate LC and JavaScript are
similar in speed.
Thanks
On Wed, Jun 5, 2013 at 4:36 PM, Monte Goulding
<monte at sweattechnologies.com>wrote:
> Actually the original code was adding the string and ! To itself so it
> grew exponentially rather than linearly. The final string would have been
> very very very long...
>
> --
> M E R Goulding
> Software development services
>
> mergExt - There's an external for that!
>
> On 05/06/2013, at 6:07 PM, Peter W A Wood <peterwawood at gmail.com> wrote:
>
> > Thanks. It does indeed take only 165 milliseconds (on my machine). I
> guess that does re-inforce my warning of the dangers of such comparisons :-)
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
More information about the use-livecode
mailing list