On Tue, Apr 10, 2007 at 02:09:19PM +0300, Roman Kyrylych wrote:
2007/4/10, Nagy Gabor <ngaba@petra.hos.u-szeged.hu>:
:S maybe i did something wrong at asmutils compile, but seems it is not faster :S its slower.
Yes, I also found that asmutils is slower. (asmutils: OS = LINUX, KERNEL = 26, OPTIMIZE = SPEED, SYSCALL = KERNEL vs. coreutils 6.9-1 standard i686 AL package)
asmutils: --------- real 0m1.473s user 0m0.734s sys 0m0.302s
coreutils: ---------- real 0m1.103s user 0m0.194s sys 0m0.035s
This means that asmutils use slower algorithm. The _same_ code written in C and assembler cannot be slower in assembler by definition. One cannot made C code faster by _just_ rewriting it in assembler, but assembler allows better processing using internal registers, and easier use of MMX/SSE/etc. Correct use of assembler (not just "let's rewrite it in asm because it's faaaast!!!") does make code faster.
Some people argue that compilers can do a much better job of register allocation and code optimization than people can. I believe in most non-trivial cases they're probably right. Jason