It is currently Sat Oct 21, 2017 1:22 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: Fri Nov 12, 2010 10:07 am 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
You should still code as a multiply/divide if that better expresses the intent, and leave optimization to those sections of code that you've identified as hotspots.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 12, 2010 10:24 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19113
Location: NE Indiana, USA (NTSC)
True, but as a rule, division by a variable is hard to pipeline in modern CPU hardware. So any inner loop with a division in it should be one of the first targets of your profiling instrumentation.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 12, 2010 11:14 am 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
The target of your profiling should be the entire program, because you shouldn't make assumptions as to what the hotspots are. Profiling then tells you where to focus your optimization efforts. If a loop has a division but isn't a hotspot, then you ignore it.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 12, 2010 11:46 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19113
Location: NE Indiana, USA (NTSC)
Profiling every function call in the entire program will just tell you that 50% of the time is spent in the profiler.

Relying on division, floating-point operations, etc. on platforms where they are slow will result in uniformly slow code.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 12, 2010 12:43 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
tepples wrote:
Profiling every function call in the entire program will just tell you that 50% of the time is spent in the profiler.

Then you're using the wrong profiling tool. A good one shouldn't impact program performance much at all. There are two basic types I know about. One hooks into every function call, giving information about number of calls, average time spent, call graph. The other doesn't modify the code at all, instead sampling the program counter hundreds of times a second, seeing where it falls. From this it determines which functions it spends the most time in. Even for the one that hooks into functions, it should have a way to avoid doing so for inline functions, lessening the impact.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group