Peter Tribble wrote:
> On Thu, Sep 10, 2009 at 8:38 AM, Raymond Wong<[email protected]> wrote:
[snip]
> while read a
> do
> line=$(($line+1))
> done
This will run even faster if you remove the '$', put the assignment
inside the arithmetric expression and declare "line" as integer
variable, e.g. ...
-- snip --
integer line=0
while read a ; do
(( line=line+1 ))
done
-- snip --
These optimisations make sure that the shell won't do any unneccesary
string-to-integer and integer-to-string conversions which consume lots
of time. For floating-point values they are even a huge problem since
strings used base10 and the internal IEEE754 floats use base2 and the
string-to-float and float-to-string conversions trigger rounding
problems...
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) [email protected]
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
_______________________________________________
perf-discuss mailing list
[email protected]