>from time to time there are posts concerning speed. i was doing some for me >and thought to post the results. > >i set up 2 loops, so that the following were called 10,000,000 times, and >then averaged the results over 5 tests and rounded to nearest whole number. >time in ticks, smaller is better: > >x=x+1 : 405 >x++ : 551 >inc(x): 548 >x+=1 : 404 > >x=x-1 : 403 >x-- : 538 >dec(x): 539 >x-=1 : 403 >this is on an iBook 500 MHz, standard runtime. There are plenty of pitfalls in the accurate timing of code. Two considerations provide a warning against accepting the above results uncritically. 1. Calculating the "per statement" time, from information given above, suggests that each statement took 600-900 nanoseconds. It is hard to believe that a 500 MHz processor could work so slowly, even in 68K with register off. In a PPC compile with register variables on, I would expect the true statement times to be in the low nanosecond range. 2. If x is a long or unsigned long, the compiler emits identical assembly code for the four alternative forms x=x+1 : x++ : inc(x) : x+=1 A convincing demonstration of speed differences would therefore set us an interesting puzzle. Robert P.