18.05.2015, 23:04
Quisiera saber como calcular la velocidad de un procesador de comandos.Gracias
new tick[2];
tick[0] = GetTickCount();
CallLocalFunction("OnPlayerPerformCommand", "issi", playerid, cmd, cmdtext[count], CallLocalFunction(functionname, "iss", playerid, cmd, cmdtext[count]));
tick[1] = GetTickCount();
new tick[2];
tick[0] = GetTickCount();
for(new i = 0; i < 100000; i ++)
{
cmd_test(playerid, "");
}
tick[1] = GetTickCount();
printf("%d", tick[1] - tick[0]);
CMD:test(playerid, params[])
{
return 1;
}
main()
{
print("Testing de comandos iniciado.");
#define ITERACIONES (10000) // Numero de iteraciones
new
CommandType[2]; /* Por ejemplo, puede ser que CommandType[0] almacene la prueba de ZCMD ..
y CommandType[1] almacene la de otro comando, si solo pruebas uno no usar array. */
CommandType[0] = GetTickCount(); // Almacena el tiempo actual desde que se inicio el server, pero sirve para contar milisegundos
while(++i != ITERACIONES) { // Creamos un ciclo que aumenta la variable i por el numero de ITERACIONES
cmd_comando(0, "\1"); // ejecuta el comando
}
printf( "ZCMD -> %d ms", CommandType[0] - GetTickCount()); // Muestra el tiempo en MS [Milisegundos]
}
CMD:comando(playerid, params[])
return SendClientMessage(playerid, -1, "algo .."); // Para que el comando no este vacio y haga algo, auque no se si se ejecute ..;