Performance Comparisons
Speed, give me what I need...
There are many different script languages - three I am familiar with are
AWK, Perl and Tcl. This page tries to establish some idea of the performance of these
languages, and of different AWK implementations.
The following are the results of running the language implementations
over a number of scripts, each of which is a reasonable stress-test of
various aspects of language and data processing.
Perl, mawk, awka, gawk, tcl and nawk were all compiled using gcc, using -O
optimisation. The Awka times are based on the running time for the executable,
not the time taken for translation and compiling. The tests were performed on a Pentium II
450mhz running RedHat Linux 5.2, and all measurements are in seconds. Results may differ
slightly on other platforms.
Note: the following timings are now quite old, and may no longer be correct. One day I'll get around to updating them...
Test: "Cast", Awk source, Perl
source
awka: ------------------- (38.51)
gawk: ----------------------- (47.44)
mawk: ----------------------------------------- (85.74)
nawk: -------------------------------------------------- (105.59)
perl: ----------------------- (47.65)
Test: "Array 1", Awk Source, Perl
source, Tcl source
awka: ------------------ (20.42)
gawk: ----------------------------- (32.58)
mawk: -------------------------------------------------- (57.71)
nawk: ----------------------------------------------- (53.55)
perl: -------------------------------- (36.45)
tcl: ---------------------------------- (39.20)
Test: "Array 2", Awk Source, Perl
source, Tcl source
awka: ---- (6.41)
gawk: ---------------------- (43.01)
mawk: ---- (7.73)
nawk: -------------------------------------------------- (99.04)
perl: ---------------------------------- (66.04)
tcl: -------------------------- (49.84)
Test: "Array 3", Awk Source, Perl
source, Tcl source
awka: --------- (17.93)
gawk: -------------------- (39.07)
mawk: -------------------------------------------------- (100.47)
nawk: ------------------------- (49.69)
perl: ------------------- (36.77)
tcl: ------------------------------------ (71.56)
Test: "I/O", Awk Source, Perl
source, Tcl source
awka: --------- (18.79)
gawk: ------------------ (39.46)
mawk: ------------ (26.62)
nawk: ---------------------------------------- (91.71)
perl: ---------------------------- (64.26)
tcl: -------------------------------------------------- (115.05)
Test: "Split", Awk Source, Perl
Source
awka: --------- (32.69)
gawk: --------------------- (80.94)
mawk: ------- (24.12)
nawk: -------------------------------------------------- (197.53)
perl: ---------------- (62.87)
Test: "Function", Awk Source, Perl
Source
awka: ---------- (36.22)
gawk: -------------------------------------------------- (200.74)
mawk: -------- (31.21)
nawk: ------------------------------------- (147.79)
perl: -------------------- (79.25)
Test: "Expression", Awk Source, Perl
Source
awka: -------------- (33.00)
gawk: ------------------------ (58.95)
mawk: ----------------- (40.72)
nawk: -------------------------------------------------- (123.80)
perl: ---------------------------------------- (98.31)
Test: "Parsecsv", Awk Source
awka: ---------------- (59.39)
gawk: ------- (25.54)
mawk: ------------------- (69.65)
nawk: -------------------------------------------------- (185.79)
Test: "Nested Loop", Awk Source, Perl Source, (input
data)
awka: --- (7.66)
gawk: -------------------- (56.67)
mawk: -------------------- (54.77)
nawk: -------------------------------------------------- (142.57)
perl: ----------------- (45.92)
Test: "Regexp", Awk Source
awka: ----------------------------------------- (22.07)
gawk: -------------------------------------------------- (27.51)
mawk: -------------- (7.57)
nawk: ---------------------------------------------- (24.77)
I am always interested in new benchmark examples - if you have one, I'd
be happy to include it here. I'd also like to have some idea how other Awk
implementations such as TAWK and MKS Awk compare to the above.
Andrew Sumner - (andrewsumner at users.sourceforge.net)
visitors
since I added this counter. |