> Ok thanks everyone. I looked over theo's notes. That helped a bit. I
> don't think the string plug in will help at all.
Sorry. It has it's uses, but it can't solve everything.
> I started speed testing the interpreter today. It is really not to
> slow for a lot of uses.
> It is just that I am using it for scripting behaviors for games. For a
> few sprites on screen at a times it is great. For 300 sprites all
> calling a behavior at 30 FPS making 9000 script calls it is slow.
That's quite a lot. Why not post your bottle necks? Do you have any
instinct as to where the bottle necks are?
Here is a neat trick:
Press command shift period, while running your app, and you are most
likely to break into the section of code that your app uses the most!
So basically, you do this say, 20x, and if you find that you happen to
jump into a certain section of code almost all the time, this is a
bottleneck.
If you posted your bottlenecks, we could perhaps speed up your code.
I am guessing you are scripting using strings. This is nice, but SLOW.
You would do better to script using integers, basically, use some
string constants.
Eg:
Sub CacheIntegerScript()
dim mystraction as string
mystraction = GetNextLine()
if mystraction = "turn left" then
myaction = kTurnLeft //MyAction would be an integer property
end if
end Sub
Get what I mean? You can still code using strings, but don't run any
code with strings. Turn everything into integers first.
This will give you a 10x speed up at least.
> Adding MidB instead of Mid helped a bit.
> The interpreter currently preprocess the scripts into tokens
> (strings).
> Im thinking of doing more preprocessing and or possibly turning the
> tokens into a kind of byte code of numbers....
Yes.
> aka IF would equal 1 etc. I could modify the interpreter to use only
> numbers this would cut out all the string comparisions...
> Trade off the code would get kind of ugly fast with out a lot of
> comments.
No. Use constants. Make a module with loads of constants in it. It will
look neat. maybe NEATER :o)
> It would probably be worth it.
It is very worth it.
--
This email was probably cleaned with Email Cleaner, by:
Theodore H. Smith - Macintosh Consultant / Contractor.
My website: <www.elfdata.com/>
|