It seems like your 'swap_xor()' is indeed more
efficient than the 'swap_mov()' your compiler generates.
The interesting thing is: When I replace the code from my two functions by the inline code of your previous post, the swap_mov() method is... faster. I am surprised, but maybe it has something to do with the Pentium 'pipelined' processing/caching or whatever. If you have enough time: Could you please run my program on your machine and post the results? It would be interesting to know.
>But what I said is right only for inline function. And not always
I tested it once again. On my machine, the xor-function (inline) is able to swap two integers ~ 300000000 times per second, while the mov-function does this ~ 330000000 times.
This shows me: This is _no_ real difference. Let's stop this discussion here (- although I enjoyed it -) as long as someone needs a program that has to swap one gazillion or more integers.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.