On Tue, Feb 21, 2012 at 2:09 PM, Dick Kriesel <dick.krie...@mail.com> wrote:
> On Feb 20, 2012, at 9:37 PM, Kay C Lan wrote: > > > Anyone want to test the speed of finding data in a 1000000 line variable > > using char -1 of word -1 of item -1 of line -1? > > Hi, Kay. Sure. How do I get the script? > > I'd guess that almost all the time goes into the line -1, and within that > line there are so few items and words and chars that the engine will eat > them in an instant, at least relatively speaking. > > The suggestion was more tongue-in-cheek. And yes you are correct for as Geoff clearly stated, it all comes down to size. If you want to poke the rattlesnake though, here is a script to test the difference between forward referencing and backward (-1) referencing. For safety reasons it's currently set to only '10', that's 10 lines, of 10 items of 10 words of 10 char. If you'd like to change that to 1000, be my guest, but I don't think you are going to prove anything we don't already know; backwards referencing is slower than forward referencing: tStore is 10 lines of 10 items of 10 words of 10 chars created in 2ms Searching tStore 10000 times Finding using forward direct reference = 141ms Finding using -1 direct reference = 234ms Oh, and if you are foolish enough to change that 10 to a 1000, by my calculations we'll not hear from you for 200 DAYS! 100 should take about 30 min. And you volunteered for a million! on mouseUp put 10 into tRepeats put the millisec into tStartTime repeat tRepeats times --lines repeat tRepeats times --items repeat tRepeats times --words put " " after tStore repeat tRepeats times --chars put "a" after tStore end repeat end repeat put "," after tStore end repeat put cr into char -1 of tStore end repeat put the millisec into tEndTime put "tStore is " & tRepeats & " lines of " & \ tRepeats & " items of " & tRepeats & \ " words of " & tRepeats & " chars created in " & (tEndTime - tStartTime) & "ms" & cr into msg put 10000 into tCycles put "Searching tStore " & tCycles & " times" & cr after msg put the millisec into tStartTime repeat tCycles times put char tRepeats of word tRepeats of item tRepeats of line tRepeats of tStore into tStore2 end repeat put the millisec into tEndTime put "Finding using forward direct reference = " \ & (tEndTime - tStartTime) & "ms" & cr after msg put the millisec into tStartTime repeat tCycles times put char -1 of word -1 of item -1 of line -1 of tStore into tStore2 end repeat put the millisec into tEndTime put "Finding using -1 direct reference = " \ & (tEndTime - tStartTime) & "ms" & cr after msg end mouseUp _______________________________________________ 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