"Russ" <18k11tm001@sneakemail.com> a �crit dans le message news: bebbba07.0306031101.6ca6a8d6@posting.google.com... > I actually did this test in C++ several years ago. The "+=" form was > about three to four times faster. If you're telling me that is not > true for Ada, I can only conclude that either 1) you did not implement > it properly, or 2) Ada itself does not implement the procedure > equivalent to "+=" very efficiently. Tests in other languages are irrelevant. Since C++ has the += operator, it will not try to optimize A = A+B Similarly, translation of FORTRAN benchmarks in Ada give awfull results. The reason is that there are lots of checks to verify that: DO 10 I = 1, N 10 A(I) = B(I) is correctly optimized into a block copy. Ada compilers don't do that optimization, since people would rather write: A := B. > Think of it this way: > > A := A + B > > is equivalent to > > temp := A -- create temp and copy into it > temp += B -- perform addition > A := temp -- copy back over to A > > How could that possibly be more efficient that simply A += B? > As I mentioned, we are talking about big arrays passed as parameters. If you use a temp, the temp is in the stack. If you access the variable directly, the address of the variable is in the stack. Therefore, any reference to an array element will need an extra dereferencing. That can make a difference. -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr