Variables vs Defines compare -> Possible?
#1

Hi.
First of all: Sorry for the title. I already made it but I don't really know if it's a good script.
However, my question is, is the script below good to compare defines vs variables?

pawn Code:
#include <a_samp>

#define COLOR_RED 0xFF0000AA
new COLOR_RED2 = 0xFF0000AA;

public OnFilterScriptInit()
{
    new time[2][2];
    time[0][0] = GetTickCount();
    for(new i = 0; i != 50000; i++)
        SendClientMessageToAll(COLOR_RED, "Nothing");
    time[0][1] = GetTickCount();
    time[1][0] = GetTickCount(); //Lol not needed
    for(new i = 0; i != 50000; i++)
        SendClientMessageToAll(COLOR_RED2, "Nothing");
    time[1][1] = GetTickCount();
    printf("DEFINE: %d", time[0][1] - time[0][0]);
    printf("VARIABLE: %d", time[1][1] - time[1][0]);
    return 1;
}
Results: (5 tests):
Code:
TEST 1:

DEFINE: 105
VARIABLE: 81

TEST 2:

DEFINE: 101
VARIABLE: 81

TEST 3:

DEFINE: 108
VARIABLE: 81

TEST 4:

DEFINE: 123
VARIABLE: 80

TEST 5:

DEFINE: 103
VARIABLE: 81
This would mean that variables are faster, but is this a good test?

- Kevin
Reply
#2

As I know, test also depends from your computer.
Reply
#3

I made this because someone said that it can't be compared, so I gave it a try
However, if defines are faster this script is pure shЎt, because it returned faster results for variables :')
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)