Performance Mystery Solved - IT'S THE DATA STUPID!!

Monte Goulding monte at sweattechnologies.com
Thu Nov 11 21:49:52 EST 2010


> There's probably some nuance I'm missing - here's a quick test which first uses the fileName of a stack to access a property, then the next run it opens the stack and gets the property by referring to the stack's short name (FWIW, I had saved the stack previously with its destroyStack set to true to try to maximize any load difference):
> 
> 
> on mouseUp
>  put 10000 into n
>  put fld "file" into tStackFile
>  --
>  put the millisecs into t
>  repeat n
>    put the uTest of stack tStackFile into r1
>  end repeat
>  put the millisecs - t into t1
>  --
>  put the millisecs into t
>  toplevel tStackFile
>  put the short name of stack tStackFile into tStack
>  repeat n
>    put the uTest of stack tStack into r2
>  end repeat
>  close stack tStackFile
>  put the millisecs - t into t2
>  --
>  put t1 && t2 &&(r1=r2) into fld "r"
> end mouseUp
> 
> Result:  151 140 true
> 
> The difference is small even across 10,000 iterations, and can be explained by the need to resolve the path to a stack reference.
> 
> How can this test be modified to show a greater difference?

Good question. It was iterating over the controls in a stack so I'm not sure if that would make any difference. I believe the user had something like 20000 graphics on a card. I can't remember if the destroyStack was true or not. 

I ran a quick test with a stack with 500 graphics and a slightly different script:
on mouseUp
    put fld "file" into tStackFile
    --
   delete stack tStackFile
    put the millisecs into t
    repeat with X=1 to the number of grcs of stack tStackFile
         put the uTest of grc X of stack tStackFile into r1
    end repeat
    put the millisecs - t into t1
    --
    delete stack tStackFile
   put the millisecs into t
    toplevel tStackFile
    put the short name of stack tStackFile into tStack
    repeat with X=1 to the number of grcs of stack tStack
         put the uTest of grc X of stack tStack into r2
    end repeat
    close stack tStackFile
    put the millisecs - t into t2
    --
    put t1 && t2 &&(r1=r2) into fld "r"
end mouseUp

Result: 1034 212 true

There was no significant difference with destroyStack property true or false. Adding another 500 graphics to the card resulted in this:
8863 399 true

Changing toplevel to go invisible stack resulted in this:
8596 72 true

Cheers

Monte


More information about the use-livecode mailing list