Re: poke - peek Speed?

new topic     » goto parent     » topic index » view thread      » older message » newer message

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu