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 on 2008-02-10
Tags: