How Much speed the usage of Bitwise operations bring ?
As we know with Bitwise operators we can make some opearations as
a) multiplyin 2 or dividing by 2
b) swipping two variable values without a need of a third one
c) changin some part of a Variable that hold many knowledges
(for ex: taking the RED bytes from a COLORREF)
all i am curious is How much Speed does Usage or bitwise operations bring?is it significant or unimportant?
Quote:Original post by tonymontana
As we know with Bitwise operators we can make some opearations as
a) multiplyin 2 or dividing by 2
b) swipping two variable values without a need of a third one
c) changin some part of a Variable that hold many knowledges
(for ex: taking the RED bytes from a COLORREF)
all i am curious is How much Speed does Usage or bitwise operations bring?is it significant or unimportant?
- Very little. Your compiler will generally optimize such situations better than you can. Performance gains will be better made by profiling first, then adjusting your algorithms, and finally focusing on more specific optimizations, like such tiny things as bitwise operations.
- Change your signature.
Holy crap! is that your sig?
Anyway, in terms of performance, bitwise operators are as cheap as you can get. Most (maybe all) bitwise operations can be done in a single processor step.
Anyway, in terms of performance, bitwise operators are as cheap as you can get. Most (maybe all) bitwise operations can be done in a single processor step.
Your signature is so long as to be annoying. Instead of putting the whole thing in your signature, provide a link to it.
no
because i am a free-man i will not change it
and because you are a moderator.ý have to say that iwill not post it much but i liked it.
any disagreement?
because i am a free-man i will not change it
and because you are a moderator.ý have to say that iwill not post it much but i liked it.
any disagreement?
I suppose it depends on what you substitute with bitwise operators. Working on a software renderer I found a huge performance increase when switching from floating point to fixed point, using left and right shift to multiply, devide and otherwise manipulate decimal numbers and store them as integers.
On the subject of your sig, change it please. This isnt an attack on the content of your sig, rather the size of it.
On the subject of your sig, change it please. This isnt an attack on the content of your sig, rather the size of it.
Definetly agree with Washu.
If you look at the actual code that your compiler produces, you'll notice that (if its a decent compiler) almost all int*2 or int/2 will be substituted with a bit-shift because the compiler is trying to optimize your code. Also, trying to bitshift a floating point types will produce unwanted results, so if you need to be accurate to some decimal places, then you'll need to multiply/divide anyways.
Unless you really need to save any extra memory you can, this isn't going to make any noticeable difference.
Being in the "for Beginners" section, I assume you've heard that bitwise operators are faster from books, which also mention the interger math is much faster than floating point. However, I believe that Pentium 4 and considerable level processors perform floating point math as fast or faster than interger math, so many of these optimizations are really not gaining you any time at all. Like Washu mentioned, the best idea is to profile your code and target the slowest sections. Optimizing a single algorithm can give you a huge performance boost if you were just coding it to make it work at first.
----------------------------------------------------------
I won't comment on the signature because I think enough has been said
Quote:a) multiplyin 2 or dividing by 2
If you look at the actual code that your compiler produces, you'll notice that (if its a decent compiler) almost all int*2 or int/2 will be substituted with a bit-shift because the compiler is trying to optimize your code. Also, trying to bitshift a floating point types will produce unwanted results, so if you need to be accurate to some decimal places, then you'll need to multiply/divide anyways.
Quote:b) swipping two variable values without a need of a third one
Unless you really need to save any extra memory you can, this isn't going to make any noticeable difference.
Being in the "for Beginners" section, I assume you've heard that bitwise operators are faster from books, which also mention the interger math is much faster than floating point. However, I believe that Pentium 4 and considerable level processors perform floating point math as fast or faster than interger math, so many of these optimizations are really not gaining you any time at all. Like Washu mentioned, the best idea is to profile your code and target the slowest sections. Optimizing a single algorithm can give you a huge performance boost if you were just coding it to make it work at first.
----------------------------------------------------------
I won't comment on the signature because I think enough has been said
Quote:Original post by tonymontanaI can simply flip a bit in your profile and make it impossible for you to use a signature at all. If you don't change your signature volutarily, I'll do exactly that.
no
because i am a free-man i will not change it
and because you are a moderator.ý have to say that iwill not post it much but i liked it.
any disagreement?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement