AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved] Optimize code (https://forums.alliedmods.net/showthread.php?t=156022)

ProIcons 04-29-2011 20:15

[Solved] Optimize code
 
i Have this array:
c{ new _:RoundData[ MAXPLAYERS ][ MAXPLAYERS ][ 32 ][ 9 ][ Score ][ 3 ] };
and i want to take each entry from inside and to upload it into a mysql server
well i make a code :P but only in the compilation took 11 Seconds so i just don't want to thing how much time will take on server
Anyway to Optimize it?:P
this is the code:
Code:
for (new i=1;i<= g_iNumPlayers + g_subs; i++) {         for (new a=1;a<= g_TeamAScore + g_TeamBScore;a++) {             for (new p=1;p<= g_iNumPlayers + g_subs;p++) {                 if (i != p) {                     for (new k=0;k < 32;k++) {                         for (new z=0;z < 9;z++) {                             if (d{RoundData[ i ][ p ][ k ][ z ][ Kills ][ a ]}) {                                 format( szQuery, 900,"INSERT INTO `stats_roundstats` VALUES ('%d', '%s', '%d', '1', '0', '0', '%s','%d','%d');",g_id,g_player[i],a,g_player[p],k,z)                                 query = SQL_PrepareQuery( g_DB, szQuery );                                 SQL_Execute( query )                             }                             else if (d{RoundData[ i ][ p ][ k ][ z ][ Deaths ][ a ]}) {                                 format( szQuery, 900,"INSERT INTO `stats_roundstats` VALUES ('%d', '%s', '%d', '0', '1', '0', '%s','%d','%d');",g_id,g_player[i],a,g_player[p],k,z)                                 query = SQL_PrepareQuery( g_DB, szQuery );                                 SQL_Execute( query )                             }                             else if (d{RoundData[ i ][ p ][ k ][ z ][ Tks ][ a ]}) {                                 format( szQuery, 900,"INSERT INTO `stats_roundstats` VALUES ('%d', '%s', '%d', '0', '0', '1', '%s','%d','%d');",g_id,g_player[i],a,g_player[p],k,z)                                 query = SQL_PrepareQuery( g_DB, szQuery );                                 SQL_Execute( query )                             }                         }                     }                 }             }         }     }

ProIcons 04-29-2011 20:37

Re: Optimize code
 
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Gather.sma(1344) : warning 203: symbol is never used: "HitPlaceStrings"
Gather.sma(1344) : warning 203: symbol is never used: "WeaponShortNames"
Gather.sma(1344) : warning 203: symbol is never used: "hud"
Header size: 2548 bytes
Code size: 56240 bytes
Data size: 34304596 bytes
Stack/heap size: 16384 bytes; max. usage is unknown, due to recursion
Total requirements: 34379768 bytes

3 Warnings.
Done.

Compilation Time: 11,00 sec

Bugsy 04-29-2011 22:13

Re: Optimize code
 
Do you really need an array with that many dimensions? Just saying.

ProIcons 04-29-2011 22:24

Re: Optimize code
 
i tested it and it works fine [only 4 ms freeze]... And yes i want it :D anyway case: solved..


All times are GMT -4. The time now is 04:31.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.