Raised This Month: $ Target: $400
 0% 

[Solved] Optimize code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-29-2011 , 20:15   [Solved] Optimize code
Reply With Quote #1

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 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?
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 )                             }                         }                     }                 }             }         }     }
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))

Last edited by ProIcons; 04-29-2011 at 22:25. Reason: Solved
ProIcons is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-29-2011 , 20:37   Re: Optimize code
Reply With Quote #2

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
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-29-2011 , 22:13   Re: Optimize code
Reply With Quote #3

Do you really need an array with that many dimensions? Just saying.
__________________
Bugsy is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-29-2011 , 22:24   Re: Optimize code
Reply With Quote #4

i tested it and it works fine [only 4 ms freeze]... And yes i want it anyway case: solved..
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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