Hi!

According to the documentation, mawk is preferred over gawk because it
is faster.  Here's an interesting phenomenon:

| ~/src/fileutils % time AWK=mawk ~ace/autoconf -m ~ace
| 16,40s user 0,26s system 95% cpu 17,512 total
| ~/src/fileutils % time AWK=gawk ~ace/autoconf -m ~ace
|  7,68s user 0,27s system 98% cpu 8,067 total

What's so expensive is the finalizing loop which uses a small AWK
script.  If you concentrate the measure on this very script, the
performance penalty is frightening:

| ~/src/fileutils % cat > /tmp/finalize.awk
|     {
|       sub(/[         ]*$/, "")
|       if ($0 == "")
|         {
|           if (!duplicate)
|             print
|           duplicate = 1
|           next
|         }
|       duplicate = 0
|       oline++
|       while (sub(/__oline__/, oline))
|         continue
|       while (sub(/@<:@/, "["))
|         continue
|       while (sub(/@:>@/, "]"))
|         continue
|       while (sub(/@S\|@/, "$"))
|         continue
|       while (sub(/@%:@/, "#"))
|         continue
|       print
|     }
| ~/src/fileutils % time mawk -f /tmp/finalize.awk < configure >/dev/null
|   9,51s user 0,02s system 100% cpu 9,521 total
| ~/src/fileutils % time gawk -f /tmp/finalize.awk < configure >/dev/null
|   0,89s user 0,01s system 101% cpu 0,890 total

So, should we change AC_PROG_AWK?  Should the package Autoconf use a
different macro?

        Akim

Reply via email to