Thousands of Graphics = Bad Performance
ambassador at fourthworld.com
Mon Feb 7 14:27:49 EST 2005
Thomas Gutzmann wrote:
> some time ago I discussed with some of you ways to display very "heavy"
> graphics in Rev at an acceptable speed.
> Well - I failed. I think if I want to do it with Rev, I have to write
> some sort of plugin.
> I tried:
> - set the properties of the templateGraphic, so only the positions and
> lengths of the graphics had to be changed before actually drawing them
> - lock messages and screen, of course
> - draw 2000 objects
> -> this alone took up to 14 seconds (PB 17" 1 GHz 2 GB), though I tried
> to save cycles
> - then scrolling these objects takes 3 seconds :-(
Must be something else at play there, as my PBG4 15" has the same clock
speed as your and has less RAM (only 768MB) and yet the graphics scroll
instantly and take only 1.4 seconds to create with this script:
-- delete old grcs from last run:
repeat with i = 1 to the number of grcs
delete grc 1
if the optionkey is down then exit to top
-- run test:
set the vscroll of grp 1 to 0
set the lockloc of the templategraphic to true
set the height of the templategraphic to 10
put the milliseconds into t
create grc in group 1
if the number of last grc > 1 then
set the topleft of last grc to \
the bottomleft of grc (the number of grcs - 1)
put the milliseconds - t &cr& the number of grcs
end mouseUpliseconds - t &cr& the number of grcs
I do a lot of dynamic object creation in Transcript and have been
consistently impressed with its very acceptable (sometimes amazing) speed.
As a stress test for a scrolling bug I'd found (long since fixed) I once
created a scrolling group with 8000 graphics in it -- no problem with
either creation or scrolling in that test. With a fourth as many
objects your situation should go swimmingly.
I'm confident we found find the bottleneck in your code if you can post it.
Tip: the clone command is very fast too, with the added benefit of
letting you visually create the desired object rather than having to
define all of its properties in code. You can even "clone into" a group
from anywhere the source object may reside, so you could have a substack
with a bunch of your own template objects for such use.
An alternative approach would be to set the properties of the
templateGraphic to the properties of your own template object, and then
use the create command as you're doing now. I haven't tested whether
clone is faster or slower than create (anyone have time to benchmark
that?), but either way you get to define your object visually and save a
lot of typing. :)
Fourth World Media Corporation
Ambassador at FourthWorld.com http://www.FourthWorld.com
More information about the Use-livecode