Re: Speed: sprintf vs. & operator

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

Jordah Ferguson writes:
>  s =s&c&list[i]
>
> versus...
>
>  s =s&c
>  s=s&list[i]

I didn't time it, but I think the first one will be
slightly faster in 2.4 than the second. 
Only slightly, because c is an atom (integer) 
in this case, and s = s & c should be fairly fast.

If you are obsessed with speed,
you could have a different statement for every
number of items (up to some limit), e.g.

if length(list) = 1 then ...
    s = ...
elsif length(list) = 2 then ...
    s = ...
elsif length(list) = 3 then
    s = list[1] & c & list[2] & c & list[3]  -- for example

elsif length(list) = 4 then
    s = ...

elsif ...

else
    -- handle larger numbers with a loop, 
    -- doing 5 at a time or something
end if

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