What of this methods is more efficient and effective? -
JavoDiaz - 26.12.2012
What of this methods is more efficient and effective?
DOUBT 1
Which is more efficient between these cases?
Case 1:
Case 2:
Case 3:
Case 4:
pawn Код:
stock const TEST = "test";
DOUBT 2
Which is more efficient between these cases?
Case 1:
Case 2:
Case 3:
Case 4:
Thanks.
Re: What of this methods is faster? -
Ballu Miaa - 26.12.2012
Strings and Integers? Both are used for different things. Why do you even want to compare whos faster in it?
Re: What of this methods is faster? -
Mafioso97 - 26.12.2012
^
You're kind of confusing...Why are you comparing them in the first place?
Re: What of this methods is faster? -
Lordzy - 26.12.2012
Err, well they're being used for various purposes. You can test them yourself using 'GetTickCount' function. Just like:
pawn Код:
public OnFilterScriptInit()
{
new tick = GetTickCount();
static test = 5;
printf("Time taken while executing filterscript with static test %d : %d", test, GetTickCount() - tick);
return 1;
}
Re: What of this methods is faster? -
JavoDiaz - 26.12.2012
I have edited the thread, now you understand me?
Re: What of this methods is faster? -
Mafioso97 - 26.12.2012
Use the "GetTickCount" function, very simplistic.
Re: What of this methods is faster? -
JavoDiaz - 26.12.2012
I don't mean faster, I mean efficient and effective, please someone who know could tell me please?
Re: What of this methods is faster? -
mineralo - 26.12.2012
if you use some variables which you don't want to remember it always then use define.
usually I use define for dialogs ids, like
this way better, if you want to declar CONST numbers like п = 3.14... then better use const.
if you have a lot messages or other text then use
pawn Код:
new AlotText[][2] =
{
{"Text first"},{"Text second"}
};
you can use that like this
pawn Код:
format(string,256,"( ! ) first TXT:%s second: %s",AlotText[0],AlotText[1]);
Re: What of this methods is faster? -
Vince - 26.12.2012
I know that having many macros affects the compile time. I also know that literals are faster than variables. But I honestly doubt it would have any effect at runtime if you chose to use constant variables.
In any case, using const instead of new is better if you know that the value of the variable is never to change. There are also instances where macros cannot be used. For example declaring a large array of floats.
As for keeping track of dialog ids, I use an enumerator. Guaranteed to never have a duplicate id.
Re: What of this methods is faster? -
JavoDiaz - 26.12.2012
Oh, Thanks ******. Where I can find a lot of code improvements?