04.07.2014, 16:47
Hi.
Which one of these three ways is the faster to load vehicles ? I can't run a benchmark on my computer because it's too slow and I think results will be corrupted.
First method :
Second method :
Third method :
Thanks in advance.
Which one of these three ways is the faster to load vehicles ? I can't run a benchmark on my computer because it's too slow and I think results will be corrupted.
First method :
PHP Code:
stock vehicles_Load_1()
{
new query[128];
mysql_query(MySQL, "SELECT `id` FROM `Vehicules` ORDER BY DESC LIMIT 1");
new id = cache_get_row_int(0, 1);
for(new i = 1; i < id; i++)
{
format(query, sizeof(query), "SELECT model, x, y, z, angle, col1, col2, respawn FROM Vehicles WHERE id = %d LIMIT 1", i);
mysql_tquery(MySQL, query, "OnQueryVehicleDone", "i", id);
}
return 1;
}
forward OnQueryVehicleDone(id);
public OnQueryVehicleDone(id)
{
model = cache_get_row_int(0, 1);
x = cache_get_row_float(0, 2);
y = cache_get_row_float(0, 3);
z = cache_get_row_float(0, 4);
angle = cache_get_row_float(0, 5);
col1 = cache_get_row_int(0, 6);
col2 = cache_get_row_int(0, 7);
respawn = cache_get_row_int(0, 8);
if(respawn == '\0') respawn = -1;
CreateVehicle(model, x, y, z, angle, col1, col2, respawn);
return 1;
}
PHP Code:
stock vehicles_Load_2()
{
mysql_tquery(MySQL, "SELECT * FROM Vehicules", "LoadVehicles", "");
return 1;
}
forward LoadVehicles();
public LoadVehicles()
{
new nbrVeh = cache_get_row_count();
for(new v = 1; v < nbrVeh;v++)
{
model = cache_get_row_int(0, 1);
x = cache_get_row_float(0, 2);
y = cache_get_row_float(0, 3);
z = cache_get_row_float(0, 4);
angle = cache_get_row_float(0, 5);
col1 = cache_get_row_int(0, 6);
col2 = cache_get_row_int(0, 7);
respawn = cache_get_row_int(0, 8);
if(respawn == '\0') respawn = -1;
CreateVehicle(model, x, y, z, angle, col1, col2, respawn);
}
return 1;
}
PHP Code:
stock vehicles_Load_3()
{
mysql_tquery(MySQL, "SELECT * FROM Vehicules", "Loading_Third");
return 1;
}
forward Loading_Third();
public Loading_Third()
{
new rows, fields, data[50];
cache_get_data(rows, fields, MySQL);
for(new i = 0; i < rows; i++)
{
// Variables
cache_get_field_content(i, "model", data); model = strval(data);
cache_get_field_content(i, "x", data); x = floatstr(data);
cache_get_field_content(i, "y", data); y = floatstr(data);
cache_get_field_content(i, "z", data); z = floatstr(data);
cache_get_field_content(i, "angle", data); angle = strval(data);
cache_get_field_content(i, "col1", data); col1 = strval(data);
cache_get_field_content(i, "col2", data); col2 = strval(data);
cache_get_field_content(i, "respawn", data); respawn = strval(data);
if(respawn == '\0') respawn = -1;
// On ajoute le vйhicule
AddStaticVehicleEx(model, x, y, z, angle, col1, col2, respawn);
}
}