Creations Favorites Medals Posts ID:180249
 ID:180249   Aug 3 2001, 3:56 pm Just a simple question, say I have a map with 100000 squares on it, will this proc be any faster than the latter proc? Maybe 1000 squares have a CheckVar set to 1 var/turf/T for(T in world) if(T.CheckVar >= 1) T.CheckVar = 0 ...any faster than... var/turf/T for(T in world) T.CheckVar = 0 ?? I'm just wondering if just plain setting them to 0 is any slower than checking before setting certain ones to zero. Is this understandable?
 #1 Aug 3 2001, 4:01 pm On 8/3/01 4:56 pm Foomer wrote: Just a simple question, say I have a map with 100000 squares on it, will this proc be any faster than the latter proc? Maybe 1000 squares have a CheckVar set to 1 var/turf/T for(T in world) if(T.CheckVar >= 1) T.CheckVar = 0 ...any faster than... var/turf/T for(T in world) T.CheckVar = 0 ?? I'm just wondering if just plain setting them to 0 is any slower than checking before setting certain ones to zero. Is this understandable? I just can't help myself with these topics. Anyways, I can't really answer your question directly--I don't really know that there would be that much of a difference. If you're looking for ways to speed it up, though, you might consider keeping a global (or otherwise handily accessible) list of all the turfs which have CheckVar greater than 1, and loop through those. I think, anyways--I'm not sure, and it'll probably depend on the situation. I just like lists.
 #2 Aug 3 2001, 5:41 pm On 8/3/01 4:56 pm Foomer wrote: Just a simple question, say I have a map with 100000 squares on it, will this proc be any faster than the latter proc? Maybe 1000 squares have a CheckVar set to 1 var/turf/T for(T in world) if(T.CheckVar >= 1) T.CheckVar = 0 ...any faster than... var/turf/T for(T in world) T.CheckVar = 0 ?? I'm just wondering if just plain setting them to 0 is any slower than checking before setting certain ones to zero. Is this understandable? My guess is that you have more assembly instructions getting executed with the extra check. However, this is gonna be a CPU killer no matter what. Along the lines of what Leftley said, anytime you find yourself searching 100000 things for anything, you need to take a different architectural approach. Keeping a list might be okay -- but any list related to turfs could get unacceptably big. Consider breaking down the problem space and seeing what other ways you might be able to get what you need here...
 #3 Aug 4 2001, 5:27 am On 8/3/01 4:56 pm Foomer wrote: Just a simple question, say I have a map with 100000 squares on it, will this proc be any faster than the latter proc? Maybe 1000 squares have a CheckVar set to 1 var/turf/T for(T in world) if(T.CheckVar >= 1) T.CheckVar = 0 ...any faster than... var/turf/T for(T in world) T.CheckVar = 0 ?? I'm just wondering if just plain setting them to 0 is any slower than checking before setting certain ones to zero. Is this understandable? "if" statements are traditionally some of the slowest to execute, though I'm only projecting to BYOND here... you could always run a test to find out for yourself. My personal guess is that the larger the percentage of turfs with CheckVar >= 1, the more effecient the second proc becomes relative to the first. To see this, imagine every single turf had CheckVar >= 1, suddenly, both procs are executing the exact same thing, except for the extra check. On the other hand, if turfs all = 0, the situation reverses... the second proc is setting them all for (and to) naught.