11.06.2015, 23:54
Vaya parece que ese es todavнa mas rбpido que el format + strcat, pero por poquito:










pawn Код:
// [ DEVELOPMENT GAMEMODE ]
// INCLUDES:
#include <a_samp>
// RULES:
#pragma dynamic 1000000
// DEFINES:
#define MAX_ITERATIONS 10000
// MAIN:
main()
{
print("Development Mode: format_benchmark.amx");
new string_1[10000], temp[128], tick_1[2];
tick_1[0] = GetTickCount();
for(new i = 0; i < MAX_ITERATIONS; i ++)
{
format(temp, sizeof(temp), "%d", i);
strcat(string_1, temp);
}
tick_1[1] = GetTickCount();
new string_2[10000], tick_2[2];
tick_2[0] = GetTickCount();
for(new i = 0; i < MAX_ITERATIONS; i ++)
{
format(string_2, sizeof(string_2), "%s%d", string_2, i);
}
tick_2[1] = GetTickCount();
new string_3[10000], tick_3[2], lenght;
tick_3[0] = GetTickCount();
for(new i = 0; i < MAX_ITERATIONS; i ++)
{
format(string_3[lenght], 10000 - lenght, "%d", i);
lenght = strlen(string_3);
}
tick_3[1] = GetTickCount();
printf("format and strcat: %d", tick_1[1] - tick_1[0]);
printf("format: %d", tick_2[1] - tick_2[0]);
printf("format-lenght: %d", tick_3[1] - tick_3[0]);
}
// CALLBACKS:
public OnGameModeInit()
{
return 1;
}
public OnGameModeExit()
{
return 1;
}

