|
-
Jul 2nd, 2002, 03:29 AM
#1
Thread Starter
PowerPoster
Comparison
How much performance increase if a program is using assembly as compare to WIN32 application?
-
Jul 2nd, 2002, 05:24 AM
#2
Frenzied Member
Depends on what it's used for. Usually not enough to make it worth the extra effort.
Generally the 80:20 rule applies - 80% of the time your app spends executing will be in 20% of the code. That 20% is where you should spend the most effort optimising.
Harry.
"From one thing, know ten thousand things."
-
Jul 2nd, 2002, 11:50 PM
#3
Thread Starter
PowerPoster
if i mixed both into my project, will the effort worth it?
As the performance is the highest piority in my application.
-
Jul 3rd, 2002, 11:45 AM
#4
Frenzied Member
It's hard to say, Chris, that's a question you'd have to answer yourself. My suggestion would be this:
1) Write the app however you know best, like in C or whatever.
2) Use some kind of performance measurement software (VC++ may have this capability, I have no idea), or even just do your own logging, to see what blocks of code are getting run the most often and are taking up the most CPU time.
3) Have a good look at this code as that's where you need to optimise. Firstly, look for changes in approach to the problem. Are there more efficient algorithms for this situation?
4) If you're satisfied that you have the best algorithm for the job, make optimisations in whatever the language you're using is. Use bitshifts and additions instead of multiplications by constants. Approximate square roots, don't calculate them. Don't dereference the same pointer over and over again, store the value in a local variable. Make functions inline, or replace them with macros, to reduce the number of function calls and their associated overhead. That kind of thing.
5) If you really need to, write it in assembly. This should be a last resort as most modern C compilers already do a pretty good job of optimising things for you, and often you won't be able to make any significant difference at this level.
Since you're talking Win32, you won't need to worry about the platform independence headaches ASM can cause. In general (and in my opinion) you should avoid writing assembly code nowadays unless it's clear that it's going to help. Writing very optimised assembly code is a black art that is really quite difficult, and can make your code very hard to follow. Usually you will get better returns on your effort from writing better algorithms and implementing them more quickly in an easier language.
Harry.
"From one thing, know ten thousand things."
-
Jul 3rd, 2002, 09:38 PM
#5
Thread Starter
PowerPoster
Thx Harry, i know what i shoudl do
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|