• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Speeding up XCode?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Speeding up XCode?


  • Subject: Re: Speeding up XCode?
  • From: Robert Dell <email@hidden>
  • Date: Tue, 18 Oct 2005 17:57:17 -0400

The code was written as it was to take advantage of ease of modification for the future.  I agree and am contemplating one routine that will read in a "reqs" text file that has all the reqs for a specific guild and one routine that will make calculations based on information in that text file.  that way when i leave the game, others can keep updating the reqs when simu decides to change something (like they LOVE to do to throw off everybody's calculations).
I've also noticed something else i can change in the whole mess (nextcircle-70) can be put into a temp variable and accessed that way within it's scope.

<and it seems to me that it is desperately crying out for more use of functions to replace all the repetitive code.>

let's take this one step at a time.
1) code that doesn't branch takes less time than code that branches
2) calling functions invoke branches in the code
3) my code doesn't call other routines (other than built-in math and locating the position of a certain index in an unknown location)

why then is my code "desperately crying out for more use of functions"?  are you trying to make my code run slower?

mysurvival[0].skillreqs = mysurvival[0].skillvalue - ((((nextcircle-70)*3)+180)*100);
let's see...
start out with the SORTED array mysurvival, we don't know what is where.  all we know is it's sorted out in it's numerical order based on what's allowed to be used. (1 ppc machine code instruction)
take index 0 (the fiest index) (3 ppc machine code instructions)
get the skillvalue (1 ppc machine code instruction)
store it in a register (0 ppc machine code instructions, part of the above instruction)
take nextcircle (1 ppc machine code instruction)
subtract a hard coded 70 from it (a single ppc machine code instruction)
multiply the result by 3 (another single ppc machine code instruction)
add 180 to that result (another ppc machine code instruction)
multiply that result by 100 (another ppc machine code instruction)
subtract the stored register from the current register (one ppc machine code instruction)
get survival again (one machine code instruction)
take the index 0 (3 ppc machine code instructions)
get the skillreqs location (1 ppc machine code instruction)
store the result register in the skillreqs location (1 ppc machine code instruction.

let's see, the whole thing SHOULD take 17 ppc machine code instructions if the compiler is doing it's job properly.  at 1 GHZ processor speed, it'll take the CPU 0.000000017 seconds to perform that single line.  How then is performing functions going to make it run any faster?  People that haven't grown up with 48k RAM, 1MHz machines that had to hand code for streamlined speed don't know how to optimize properly.  functions do NOT increase speed, they REDUCE the speed.



shin kurokawa wrote:

That code snippet is poorly written if it's supposed to be for a performance-critical release. But often during the initial development phase, some of us actually like writing out matrix operations like these (..though usually much more complicated than this particular example) especially when they involve very, very heavily-nested loops, if just for debugging and legibility sake --- The idea being that, once the loops(or whatever) in question do what they're supposed to do, only then we should hand-optimize by rewritng, registering the most often-accessed values, etc, at the expense of less-legible code, besides IMHO/IME optimizing during the initial coding phase seems actually counter-productive.

I wouldn't be surprised if stuff like this would
really become a non-issue as compilers' optimizers
get smarter at recognizing patterns in a given code, but
I'd be really surprised if that happened tomorrow. ;)
-Shin


Cameron Hayne wrote:


On 17-Oct-05, at 6:00 PM, Robert Dell wrote:

check it out at http://sourceforge.net/projects/yasse/
I'm sure i can break out smaller sections but then i'd only be doing lots of includes in the main file which wouldn't solve the problem as I hear you folks describing it.



I looked at that code (specifically the file yasse.m which is 22K lines) and it seems to me that it is desperately crying out for more use of functions to replace all the repetitive code.
For example, there are pages and pages of code like this:


magicreqs = magicTotal - (((nextcircle-70)*33)+1720);
i = [self getMagicPosition: @"Power"];
mymagic[i].skillreqs = mymagic[i].skillvalue-((((nextcircle-70) *6)+320)*100);
i = [self getLorePosition: @"Scholarship"];
mylore[i].skillreqs = mylore[i].skillvalue-((((nextcircle-70)*4) +210)*100);
i = [self getLorePosition: @"Teaching"];
mylore[i].skillreqs = mylore[i].skillvalue-((((nextcircle-70)*2) +140)*100);
i = [self getLorePosition: @"Astrology"];
mylore[i].skillreqs = mylore[i].skillvalue-((((nextcircle-70)*4) +180)*100);
mylore[0].skillreqs = mylore[0].skillvalue-((((nextcircle-70)*3) +180)*100);
mylore[1].skillreqs = mylore[1].skillvalue-((((nextcircle-70)*2) +0)*100);
mysurvival[0].skillreqs = mysurvival[0].skillvalue - ((((nextcircle-70)*3)+180)*100);
mysurvival[1].skillreqs = mysurvival[1].skillvalue - ((((nextcircle-70)*3)+180)*100);
mysurvival[2].skillreqs = mysurvival[2].skillvalue - ((((nextcircle-70)*2)+140)*100);
mysurvival[3].skillreqs = mysurvival[3].skillvalue - ((((nextcircle-70)*2)+140)*100);
mysurvival[4].skillreqs = mysurvival[4].skillvalue - ((((nextcircle-70)*2)+140)*100);
mysurvival[5].skillreqs = mysurvival[5].skillvalue - ((((nextcircle-70)*2)+140)*100);
mysurvival[6].skillreqs = mysurvival[6].skillvalue - ((((nextcircle-70)*2)+20)*100);
mysurvival[7].skillreqs = mysurvival[7].skillvalue - ((((nextcircle-70)*2)+20)*100);



That could (and should) be parameterized into a function. Doing that would drastically cut down on the number of lines of code. Of course it would be a fairly large amount of work to do this now. Maybe some clever regex search & replaces could do it.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Speeding up XCode?
      • From: Steve Checkoway <email@hidden>
    • Re: Speeding up XCode?
      • From: Cameron Hayne <email@hidden>
    • Re: Speeding up XCode?
      • From: Markian Hlynka <email@hidden>
References: 
 >Speeding up XCode? (From: Mark Wagner <email@hidden>)
 >Re: Speeding up XCode? (From: Robert Dell <email@hidden>)
 >Re: Speeding up XCode? (From: Cameron Hayne <email@hidden>)
 >Re: Speeding up XCode? (From: Andreas Mayer <email@hidden>)
 >Re: Speeding up XCode? (From: Robert Dell <email@hidden>)
 >Re: Speeding up XCode? (From: Cameron Hayne <email@hidden>)
 >Re: Speeding up XCode? (From: shin kurokawa <email@hidden>)

  • Prev by Date: Re: Having Image PICT NIB problem ?
  • Next by Date: Using XCode for photoshop plugins.
  • Previous by thread: Re: Speeding up XCode?
  • Next by thread: Re: Speeding up XCode?
  • Index(es):
    • Date
    • Thread