In this directory are some simple awk scripts aimed at testing
relative performance of some aspects of the language.

They are:-

  cast.awk     (lots of string to number & back casts in a loop)
  array.awk    (tests arrays with string elements)
  array2.awk   (tests arrays with integer elements)
  array3.awk   (speed accessing multi-dimension arrays)
  io.awk       (writes out a large file, reads it in & splits $0)
  split.awk    (how fast is the split functionality?)
  function.awk (many repeated function calls passing arguments)
  expr.awk     (speed evaluating a reasonably complex expression)
  parsecsv.awk (a benchmarking example from comp.lang.awk)
  loop.awk     (heavily nested for loops and if statements)

The code for these tests is pretty small - I wanted to compare
performance of the internal 'library' functions rather than
speed of interpreting vs compiled, with the exception of loop.awk,
which was so dramatic I couldn't leave it out.

If you have a good benchmark test, feel free to forward it to me.
I'd also be interested in seeing results of awka in comparison with
other AWK implementations not listed here, such as Thompson Awk
(which I dont have).

Note:  The awka tests were conducted as follows:-

  awka -f array.awk >x.c
  gcc -O x.c -L/usr/local/lib -I/usr/local/include -lawka -lm
  time a.out

Libawka.a, mawk, gawk, tcl, perl and 'the one true AWK (nawk)' used
in the tests were all compiled using gcc with an optimisation flag 
of -O.  Tcl8.0.4 and Perl5 were used.  The benchmark platform was 
a dual-CPU (450mhz) Pentium II running RedHat 5.2.  

Results may vary on different systems, probably due to variations
in how well gcc optimises code.  The results listed here should
still be a generally reliable representation.

Note to Perl users:  I rarely write in Perl, so my test programs
may not be as efficient as they could/should be.  By all means
improve them & forward me a copy.  Any takers?  Anyone?  I also
need perl scripts for the parsecsv & loop examples.

RESULTS for v0.3b-26, 30-8-99:

CAST
1. perl:   27.26 sec
2. awka:   32.89 sec
3. gawk:   33.97 sec
4. mawk:   60.79 sec
5. nawk:   61.46 sec

ARRAY
1. awka:   23.29 sec
2. gawk:   44.98 sec
3. perl:   59.22 sec
4. tcl:    61.04 sec
5. nawk:   78.08 sec
6. mawk:  174.13 sec

ARRAY2
1. awka:   41.43 sec
2. mawk:   71.24 sec
3. gawk:  323.82 sec
4. tcl:   464.33 sec
5. perl:  664.73 sec
6. nawk:  941.32 sec

ARRAY3
1. awka:   17.45 sec
2. gawk:   41.22 sec
3. nawk:   43.92 sec
4. tcl:    81.84 sec
5. perl:   99.21 sec
6. mawk:  122.41 sec

IO
1. awka:   24.06 sec
2. mawk:   30.50 sec
3. gawk:   41.71 sec
4. perl:   77.15 sec
6. nawk:  101.20 sec
7. tcl:   151.51 sec

SPLIT
1. awka:   19.78 sec
2. mawk:   26.62 sec
3. perl:   32.80 sec
4. gawk:   76.60 sec
5. nawk:  190.28 sec

FUNCTION
1. mawk:   30.69 sec
2. awka:   31.13 sec
3. perl:   72.32 sec
4. nawk:  123.28 sec
5. gawk:  180.55 sec

EXPR
1. awka:   29.03 sec
2. mawk:   36.60 sec
3. gawk:   54.90 sec
4. perl:  106.17 sec
5. nawk:  121.31 sec

PARSECSV
1. awka:   29.19 sec
2. mawk:   36.86 sec
3. gawk:   87.11 sec
4. nawk:  221.81 sec

NESTED-LOOP
1. awka:    4.34 sec
2. mawk:   34.22 sec
3. gawk:   41.94 sec
4. nawk:   85.23 sec

