Re: performance
From: djrb (rafaelbinder_at_hotmail.com)
Date: 02/10/04
- Next message: David Harmon: "Re: STL custom mem_fun"
- Previous message: Mark McIntyre: "Re: No call for Ada (was Re: Announcing new scripting/prototyping language)"
- In reply to: lallous: "Re: performance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 10 Feb 2004 12:57:59 -0800
"lallous" <lallous@lgwm.org> wrote in message news:<c0ar0p$14mjao$1@ID-161723.news.uni-berlin.de>...
> "Gregory Noulin" <gregory.noulin@inrialpes.fr> wrote in message
> news:c0aqbg$7nh$1@trompette.imag.fr...
> > I am looking for differences of cost of an equality test between 2
> > integers and a multiplication between 2 integers.
> >
> > Which operation is most costly : multiplication (*) or equality test (==)
>
> That depends on the CPU Arch. and the code produced by the compiler to do
> the comparison or multiplication.
>
> For example, on x86, the comparison might be like this:
>
> if (x == y)
>
> mov ax, x
> xor ax, y
> jz _yes_equal
>
> And multiplication:
>
> x * y
>
> mov bx, x
> mov ax, y
> mul bx
>
> So the answer relies on whether "xor" is executed faster than "mul"
> As I remember, yes , "xor" is faster.
>
> In most cases the comparison is faster than multiplication.
As far as I know, XOR takes only one clock on x86 compatibles (386 and
higher).
As to MUL, it takes much more clocks to complete (at least 2).
There is a good book on ASM at http://webster.cs.ucr.edu/AoA.html
Another source is at http://www.masm32.com/
MASM32 package contains a lot of help files where the timings of
various asm commands are specified, but, if I am not wrong, the
timings are specified only up to x386.
As for the latest P4 CPU(s), the best source is
http://www.intel.com/design/Pentium/manuals/
I hope this info will help :)
- Next message: David Harmon: "Re: STL custom mem_fun"
- Previous message: Mark McIntyre: "Re: No call for Ada (was Re: Announcing new scripting/prototyping language)"
- In reply to: lallous: "Re: performance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|