Re: Looking for awk compiler

camcta@taux01.nsc.com (Amnon Cohen )
Mon, 22 Mar 1993 09:09:20 GMT

          From comp.compilers

Related articles
Looking for awk compiler ahuang@bach.ece.cmu.edu (Andrew Shao-Chun Huang) (1993-03-16)
Re: Looking for awk compiler joshua@Veritas.COM (1993-03-18)
Re: Looking for awk compiler camcta@taux01.nsc.com (1993-03-22)
Re: Looking for awk compiler megatest!plethorax!djones@uu4.psi.com (1993-03-26)
| List of all articles for this month |

Newsgroups: comp.compilers
From: camcta@taux01.nsc.com (Amnon Cohen )
Keywords: interpreter, performance, comment
Organization: National Semiconductor, Israel
References: 93-03-058
Date: Mon, 22 Mar 1993 09:09:20 GMT

>Does anyone know of a compiler for the awk language? I have an awk
>script that takes a long time to run. I'd like to compile it directly
>to binary or to a language such as C.


The original awk interpreter had a "compile" option. This parsed the
source code into an internal tree representation, and then dumped a core
image, which could be loaded as a stand alone executable. Obviously the
resulting executable would run the same speed as the original interpreted
awk.


Before examining other awk compilers, you should consider WHY your awk
script takes so long to run. Often most of the run time is spent on
operations such as pattern matching, or associative array lookup, with
interpreted overhead accounting for a negligable fraction of the run-time.
In these (common) cases, compiling to C will not solve your problem.


If your script reads very long input files, and only processes a small
number of records, then pre-processing the file with egrep would be a big
win, since egrep scans input much faster than awk.


Large associative arrays should be avoided. These are implimented as
closed hash tables of very small size, which effectively degenerate into
linked lists when they become large.


Good Luck
Amnon Cohen
awk fanatic
Email: amnonb@taux01.nsc.com
[Do all versions of awk, e.g. nawk, gawk, and mawk, have the poorly tuned
hash tables? Seems unlikely. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.