Re: poke - peek Speed?
- Posted by Robert Craig <rds at RapidEuphoria.com> Nov 13, 2002
- 440 views
Ricardo Forno writes: > function to2bytes(integer u) > return and_bits(u, #FF) & floor(u / 256) > end function > > function to2bytesa(integer u) > poke4(Addr1, u) > return peek({Addr1, 2}) > end function > Why does the poke - peek version take more time > than the other, that uses division? I got 4.12 seconds for the first (10 million iterations, including calling rand() each time), and 5.71 seconds for the second. floor() and divide are combined into a single integer divide. and_bits() is very fast. {Addr1, 2} looks like it's free, but it isn't - a sequence is created each time - you should store {Addr1, 2} in a variable before looping. > Using allocate_low instead of allocate, > it even takes more time! allocate_low() involves a DOS interrupt which might slow things down a bit compared to allocate(). Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com