Raised This Month: $51 Target: $400
 12% 

Which of these methods creates less load for CPU?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AlexALX
Senior Member
Join Date: Apr 2009
Old 09-28-2010 , 09:53   Which of these methods creates less load for CPU?
Reply With Quote #1

Which of these methods creates less load for CPU?
PHP Code:
    // Searching entities
    
new iEntity = -1classname[32];
    while( (
iEntity engfunc(EngFunc_FindEntityInSphereiEntityFloat:{0.0,0.0,0.0}, 8192.0)) > ) {
        
classname[0] = '^0';
        
pev(iEntity,pev_classname,classname31)
        if (
containi(classname,"item_")!=-1||equali(classname,"armoury_entity")||weaponbox&&equali(classname,"weaponbox")) {
            
peviEntitypev_absming_flItemMinsg_iCount ] );
            
peviEntitypev_absmaxg_flItemMaxsg_iCount ] );
            
g_iEntg_iCount ] = iEntity;
            
g_iCount++;
        }
    } 
OR
PHP Code:
     new iEntity = -1
while( (iEntity engfunc(EngFunc_FindEntityByStringiEntity"classname""armoury_entity")) > ) {
        
peviEntitypev_absming_flItemMinsg_iCount ] );
        
peviEntitypev_absmaxg_flItemMaxsg_iCount ] );
        
g_iEntg_iCount ] = iEntity;
        
g_iCount++;
    }
iEntity = -1
    
while( (iEntity engfunc(EngFunc_FindEntityByStringiEntity"classname""item_battery")) > ) {
        
peviEntitypev_absming_flItemMinsg_iCount ] );
        
peviEntitypev_absmaxg_flItemMaxsg_iCount ] );
        
g_iEntg_iCount ] = iEntity;
        
g_iCount++;
    }
iEntity = -1
    
while( (iEntity engfunc(EngFunc_FindEntityByStringiEntity"classname""item_healthkit")) > ) {
        
peviEntitypev_absming_flItemMinsg_iCount ] );
        
peviEntitypev_absmaxg_flItemMaxsg_iCount ] );
        
g_iEntg_iCount ] = iEntity;
        
g_iCount++;
    }
iEntity = -1
    
while( (iEntity engfunc(EngFunc_FindEntityByStringiEntity"classname""item_longjump")) > ) {
        
peviEntitypev_absming_flItemMinsg_iCount ] );
        
peviEntitypev_absmaxg_flItemMaxsg_iCount ] );
        
g_iEntg_iCount ] = iEntity;
        
g_iCount++;
    }
    if (
weaponbox) {
iEntity = -1
        
while( (iEntity engfunc(EngFunc_FindEntityByStringiEntity"classname""weaponbox")) > ) {
            
peviEntitypev_absming_flItemMinsg_iCount ] );
            
peviEntitypev_absmaxg_flItemMaxsg_iCount ] );
            
g_iEntg_iCount ] = iEntity;
            
g_iCount++;
        }
    } 
...? Please help)

it should be performed every 2 seconds ... therefore important maximum optimization.

And this:

PHP Code:
#define MAX_ITEMS 192

    
for(new i=0;i<MAX_ITEMS;i++) g_iEnt[i] = 0;
    
g_iCount 0
Maybe there's a way easier to clean the array? This is done also every 2 seconds before the code that is written above (Searching entities).
__________________
AlexALX is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-28-2010 , 10:17   Re: Which of these methods creates less load for CPU?
Reply With Quote #2

Why you don't simply hook when such entities spawn?
__________________
Arkshine is offline
AlexALX
Senior Member
Join Date: Apr 2009
Old 09-28-2010 , 10:21   Re: Which of these methods creates less load for CPU?
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
Why you don't simply hook when such entities spawn?
if ent spawn on func_door and then func_door moved - this method do not work) need update coordinates...
__________________
AlexALX is offline
AlexALX
Senior Member
Join Date: Apr 2009
Old 09-28-2010 , 10:38   Re: Which of these methods creates less load for CPU?
Reply With Quote #4

And help with this:
Quote:
engfunc(EngFunc_TraceSphere, origin, origin, IGNORE_MONSTERS, 15.0, id, trace)
cs closed with error:
Quote:
TraceSphere not yet implemented
Who? how use this?
__________________
AlexALX is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 09-29-2010 , 00:07   Re: Which of these methods creates less load for CPU?
Reply With Quote #5

Quote:
Originally Posted by AlexALX View Post
if ent spawn on func_door and then func_door moved - this method do not work) need update coordinates...
What exacly do you want to do ? There are more efficient ways to check things even if they move.
__________________
Hunter-Digital is offline
AlexALX
Senior Member
Join Date: Apr 2009
Old 09-29-2010 , 03:37   Re: Which of these methods creates less load for CPU?
Reply With Quote #6

Quote:
Originally Posted by Hunter-Digital View Post
What exacly do you want to do ? There are more efficient ways to check things even if they move.
Example?
__________________
AlexALX is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 09-29-2010 , 10:20   Re: Which of these methods creates less load for CPU?
Reply With Quote #7

Example of WHAT ? I don't know what you are trying to do...
__________________
Hunter-Digital is offline
AlexALX
Senior Member
Join Date: Apr 2009
Old 09-29-2010 , 10:29   Re: Which of these methods creates less load for CPU?
Reply With Quote #8

Quote:
Originally Posted by Hunter-Digital View Post
Example of WHAT ? I don't know what you are trying to do...
i need get absmin absmax from armoury_entity (and item_*) and when armoury_entity moved update it. armoury_entity can lie on func_door and func_door moved with armoury_entity (and item_*).
__________________
AlexALX is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 09-30-2010 , 06:54   Re: Which of these methods creates less load for CPU?
Reply With Quote #9

If you want to check which one is more cpu intensive then use amx profiler
__________________
Impossible is Nothing
Sylwester 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 03:01.


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