11.09.2011, 09:19
Quote:
HI guys,
I've recently tested a code it was to see which is better I followed ******' string optimisation thread that i made i test with new str[12 char] vs new string[12] pawn Код:
luckily i can still remember it(partially) The result is: Time 1: 2900 Something Time 2: 2800 Something but thats not the point, the point is time 1 which is a packed string has more time than time 2. I'm not sure which is better + Did it count the time to finish all printf's or did it count the time it has been printed? |
pawn Код:
t1 = GetTickCount(); // Put into t1 the ms have passed since the start
for (i = 0; i < ITERATIONS; i++)
{
new string[12] = "Hello there"; //
printf(string); // Prints 10000 times "Hello there"
}
t2 = GetTickCount(); // Then get again the ms count
Try what happens if you write:
pawn Код:
#define ITERATIONS (10000)
Test()
{
new
t0,
t1,
t2,
i;
t0 = GetTickCount();
for (i = 0; i < ITERATIONS; i++)
{
printf(!"Hello there");
}
t1 = GetTickCount();
for (i = 0; i < ITERATIONS; i++)
{
printf("Hello there");
}
t2 = GetTickCount();
printf("Time 1: %04d, time 2: %04d", t1 - t0, t2 - t1);
}