A Profiling Success
[Courtesy Rob Pike]
Once upon a time, a profile of awk revealed that this loop:
for (i = 0; i < MAXFLD; i++)
clearfield(i);
|
was taking 30% of the total execution time.
To allow for large inputs, MAXFLD was set to 200, but for most
data, the actual number of fields is more like 2-3.
Modified the code to keep track of used fields:
for (i = 0; i < numfields; i++)
clearfield(i);
|
Caused awk to run 25% faster
(along with the 1000's of programs using awk )
|