How much performance increase if a program is using assembly as compare to WIN32 application?
Printable View
How much performance increase if a program is using assembly as compare to WIN32 application?
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.
if i mixed both into my project, will the effort worth it?
As the performance is the highest piority in my application.
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.
Thx Harry, i know what i shoudl do :)