07.06.2011, 13:49
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?
Results: (5 tests):
This would mean that variables are faster, but is this a good test?
- Kevin
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;
}
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
- Kevin