Raised This Month: $ Target: $400
 0% 

CPU Usage vs Memory Usage


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-25-2009 , 14:59   CPU Usage vs Memory Usage
Reply With Quote #1

Which would be a better trade-off?

Option #1:
Code:
#define MAX_ENTITY_INDEX 1600 new bool:g_special_entity[MAX_ENTITY_INDEX]; public plugin_init() {     register_forward(FM_AddToFullPack, "FwdAddToFullPack", 1);         new ent = -1;     while( (ent = find_ent_by_class(ent, "_classname_"))     && ent < MAX_ENTITY_INDEX )     {         g_special_entity[ent] = true;     } } public FwdAddToFullPack(es, e, ent, host, hostflags, player, pset) {     if( ent < MAX_ENTITY_INDEX     && g_special_entity[ent] )     {         // code     } }

Option #2:
Code:
#define SPECIAL_ENTITY 123456 public plugin_init() {     register_forward(FM_AddToFullPack, "FwdAddToFullPack", 1);         new ent = -1;     while( (ent = find_ent_by_class(ent, "_classname_")) )     {         set_pev(ent, pev_iuser1, SPECIAL_ENTITY);     } } public FwdAddToFullPack(es, e, ent, host, hostflags, player, pset) {     if( pev(ent, pev_iuser1) == SPECIAL_ENTITY )     {         // code     } }

Option #3:
(This wasn't originally included, but I'm curious)
Code:
#define MAX_ENTITY_INDEX 1600 new g_special_entity[(MAX_ENTITY_INDEX >> 5) + 1]; public plugin_init() {     register_forward(FM_AddToFullPack, "FwdAddToFullPack", 1);         new ent = -1;     while( (ent = find_ent_by_class(ent, "_classname_"))     && ent < MAX_ENTITY_INDEX )     {         g_special_entity[ent >> 5] |= (1 << (ent & 31));     } } public FwdAddToFullPack(es, e, ent, host, hostflags, player, pset) {     if( ent < MAX_ENTITY_INDEX     && (g_special_entity[ent >> 5] & (1 << (ent & 31))) )     {         // code     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 05-25-2009 at 16:01.
Exolent[jNr] is offline
 


Thread Tools
Display Modes

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 01:25.


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