Jump to content
Sign in to follow this  
Melmarkian

Performance question with script vs. function

Recommended Posts

Hi,

I recently wrote a revive script for the AI in the playerteam. The script stores things like unitname, identity and lives and then waits until the unit is !alive.

Now to my question:

I read somewhere about the preprocessor command and functions for arma2. The text said that if I use a script more than once it should be made into a function. Is there really a big difference between the functions and a simple script call? I noticed for example that UPSMON uses a the normal execVM method and I´m sure there are a lot of repeating scripts in there.

Does someone has any better insight into this or experience with this? Or some lecture about the matter?

I know this one, but its not really helping me.

http://community.bistudio.com/wiki/Code_Optimisation

Share this post


Link to post
Share on other sites

Well, it is easy to check.

Make a for cycle (eg. with 10000 cycles).

First, include the ExecVM call to your cycle, time the 10000 cycles.

Then preprocess first and call the preprocessed function in your cycle, and time the 10000cycles.

You will know the result for your script.

Afaik: a function gets loaded into memory, thus taking memory, but reading from RAM is a lot faster.

sqf files get read from the HDD and gets compiled every time (taking some CPU as well), which can be a lot slower.

I don't think that you will spot any difference with a some-line-long and not-that-often-called script. Bigger concern should be able to return variable (function) vs. not able to return (execVM)

Edited by zapat

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×