Home   Help Search Login Register  

Author Topic: call vs. execVM  (Read 1359 times)

0 Members and 1 Guest are viewing this topic.

Offline ModestNovice

  • Members
  • *
call vs. execVM
« on: 10 Dec 2008, 04:55:42 »
Hi guys, quick question.

If I'm dealing with a large sleep number, is it 'better' to execVM a script, or can I use in function?

-> script:
Code: [Select]
_amount = _this select 0;

Sleep _amount;

Hint "Done.";
;


-> function:
Code: [Select]

_MyFantasticFunction =
{
_amount = _this select 0;

[] spawn
{
Sleep _amount;

Hint "Done.";
};
};


I tested both, and they worked exactly the same, but I'm just wondering performance wise if either works better then the other.
« Last Edit: 10 Dec 2008, 04:58:20 by DaChevs »
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: call vs. execVM
« Reply #1 on: 10 Dec 2008, 09:51:36 »
If you are going to execute that code many times, then it might be better to compile it once and then use call or spawn for every execution as execVM compiles the code each time you execute the script.

Offline Ext3rmin4tor

  • Members
  • *
Re: call vs. execVM
« Reply #2 on: 10 Dec 2008, 11:35:10 »
Besides don't use "call" when you have many sleep statements since the "call" command stops the execution of the calling script until the function ends, so you should use "spawn" instead of "call" (unless you made a function which returns a value, in that case the only possible command is "call" if you want to have access to the returned value itself). You can find further info in this topic:

http://www.ofpec.com/forum/index.php?topic=32627.0
« Last Edit: 10 Dec 2008, 11:43:38 by Ext3rmin4tor »
How can you shoot women and children?
Easy! Ya' just don't lead'em so much! Ain't war hell?!!

Offline ModestNovice

  • Members
  • *
Re: call vs. execVM
« Reply #3 on: 10 Dec 2008, 22:00:25 »
yeh I need it to return or do something at the end.

Thanks for the help you two.
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley