Revolution much slower then Hypercard

Geoff Canyon gcanyon at inspiredlogic.com
Mon Feb 11 03:33:02 EST 2002


At 7:59 PM -0800 2/10/02, Geoff Canyon wrote:
>Finally, pre-loading the data into an array variable instead was faster still (not counting the time to load the array): 9 ticks. 

At 9:02 PM -0800 2/10/02, Ken Norris (dialup) wrote:
>Yeow! These are some pretty impressive numbers. The tricks you can do with
>Rev can be astounding. That last one, though it would take time to set up,
>looks like some serious industrial grade speed search. How does it work?

At 8:35 AM +0100 2/11/02, yves COPPE wrote:
>can you give an example of a script using such a code ?


Here's the array script. Using the Filter command method might or might not be applicable here -- I'd need to know more of the specifics of the problem.

By the way, with Revolution it's often fairly easy to create a performance difference of twenty or thirty times, sometimes even a hundred times, just by changing the way you write your code. If a handler is slow, be sure to look for ways to speed it up, because generally there will be a way.

regards,

Geoff


on mouseUp
-- first build the arrays. I'm not timing this,
-- because in real use this would be done once
-- beforehand, and then the arrays stored in globals.
-- even so, building the arrays only takes a few seconds

-- tLog is the results variable -- faster than a field
  put empty into tLog

-- setting the default stack for speed
  set the defaultStack to "revDocsLanguageReference"

-- figure out how many cards -- there are about 1200
  put the number of cds into tHowMany

-- repeat for each card
  repeat with i = 1 to tHowMany

-- put three fields into an array element
    put fld "summary" of cd i && fld "examples" of cd i \
    && fld "comments" of cd i into tArray[i]

-- put the name of the card into another.
-- note that I could have used the card name as the index
-- for the other array -- Rev has associative arrays, which
-- are the cat's meow. But if two cards were named the same,
-- it wouldn't work.
    put the name of cd i into tCardName[i]
  end repeat

-- reset the default stack
  set the defaultStack to "speedTest"

-- and now to the test -- start timing!
  put ticks() into tStart

  repeat with i = 1 to tHowMany

-- for each element in the array, if it contains "card"
    if tArray[i] contains "card" then

-- then put the entry in the names array after the results variable
      put tCardName[i] & cr after tLog
    end if
  end repeat

-- put the results in a field and we're done.
  put tLog into fld "log"

-- This is about 10 ticks on my machine. 
  put ticks() - tStart into tRunTime

-- display the results
  put tRunTime && (the number of lines of tLog)
end mouseUp



More information about the Use-livecode mailing list