Xana/ xana2/ 2008/ 02/ 10
For loops for fun

Raphael, what you're doing is incredibly inefficient, especially with one million string-to-integer conversions and two million back. You could do this instead:

% zsh -c 'zmodload zsh/datetime;
(( s = EPOCHSECONDS ));
for (( c = 0; c < 1000000; c++ )) do : ;
done;
print "$0 took" $(( EPOCHSECONDS - s )) "seconds to finish"'
zsh took 3 seconds to finish
Posted Sun 10 Feb 2008 08:02:38 PM EST Tags: 10