programming:general:phpvspythonvsperl
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
programming:general:phpvspythonvsperl [2008/02/01 20:47] – crustymonkey | programming:general:phpvspythonvsperl [2008/04/14 13:55] (current) – crustymonkey | ||
---|---|---|---|
Line 12: | Line 12: | ||
^ OS | Gentoo Linux | | ^ OS | Gentoo Linux | | ||
- | The second machine was my personal laptop, a **Gateway MX6931** running **Gentoo | + | The second machine was my personal laptop, a **Gateway MX6931** running **Ubuntu |
^ CPU | single, dual core Intel Core2 1.66GHz | | ^ CPU | single, dual core Intel Core2 1.66GHz | | ||
^ Memory | 2GB | | ^ Memory | 2GB | | ||
- | ^ OS | Ubuntu | + | ^ OS | Ubuntu |
==== The Interpreters ==== | ==== The Interpreters ==== | ||
Line 344: | Line 344: | ||
===== The Results ===== | ===== The Results ===== | ||
The tables below show the Unix '' | The tables below show the Unix '' | ||
+ | |||
==== The Sun Box ==== | ==== The Sun Box ==== | ||
- | | ^ PHP ^ Python (non-compiled) ^ Python (compiled) ^ Perl (interpolated string loop) ^ Perl (hard coded regexes) ^ | + | | ^ PHP ^^^ Python (non-compiled) |
- | ^ Test 1 | **real: 9.45s**, user: 9.10s, sys: 0.07s | real: 13.42s, user: 12.66s, sys: 0.11s | real: 7.97s, user: 7.20s, sys: 0.11s | real: 31.89s, **user: 29.43s**, sys: 0.17s | **real: 1.59s**, user: 1.53s, sys: 0.05s | | + | | | **Real** |
- | ^ Test 2 | real: 9.90s, user: 9.06s, **sys: 0.06s** | real: 13.28s, user: 12.45s, sys: 0.15s | real: 7.86s, user: 7.25s, **sys: 0.01s** | real: 31.78s, user: 29.97s, sys: 0.18s | real: 1.67s, user: 1.52s, sys: 0.07s | | + | ^ Test 1 | **9.45s** |
- | ^ Test 3 | real: 9.58s, user: 9.07s, **sys: 0.06s** | real: 13.56s, user: 12.59s, sys: 0.10s | real: 7.45s, **user: 7.09s**, sys: 0.13s | real: 31.29s, user: 29.61s, **sys: 0.14s** | real: 2.32s, user: 1.46s, **sys: 0.04s** | | + | ^ Test 2 | 9.90s |
- | ^ Test 4 | real: 9.52s, user: 9.08s, sys: 0.10s | real: 13.58s, user: 12.63s, **sys: 0.09s** | **real: 7.40s**, user: 7.18s, sys: 0.04s | **real: 33.19s**, user: 30.27s, sys: 0.15s | real: 1.76s, user: 1.47s, **sys: 0.04s** | | + | ^ Test 3 | 9.58s |
- | ^ Test 5 | real: 9.94s, **user: 8.87s**, sys: 0.12s | **real: 13.00s**, **user: 12.44s**, sys: 0.12s | real: 7.43s, user: 7.19s, sys: 0.08s | real: 33.22s, user: 30.22s, sys: 0.16s | real: 1.82s, **user: 1.42s**, sys: 0.10s | | + | ^ Test 4 | 9.52s |
+ | ^ Test 5 | 9.94s | ||
+ | ==== The Laptop ==== | ||
+ | | ^ PHP ^^^ Python (non-compiled) ^^^ Python (compiled) ^^^ Perl (interpolated string loop) ^^^ Perl (hard coded regexes) ^^^ | ||
+ | | | **Real** | ||
+ | ^ Test 1 | 14.25s | ||
+ | ^ Test 2 | 14.00s | ||
+ | ^ Test 3 | 14.24s | ||
+ | ^ Test 4 | **13.94s** | ||
+ | ^ Test 5 | 14.30s | ||
+ | ===== Just For Fun... ===== | ||
+ | ...one of my co-workers whipped up this C code which uses '' | ||
- | |||
- | ==== The Laptop ==== | ||
- | | ^ PHP ^ Python (non-compiled) ^ Python (compiled) ^ Perl (interpolated string loop) ^ Perl (hard coded regexes) ^ | ||
- | ^ Test 1 | real: 14.25s, user: 14.05s, sys: 0.10s | **real: 12.10s**, user: 11.98s, sys: 0.06s | **real: 6.12s**, user: 6.03s, sys: 0.07s | **real: 42.42s**, **user: 42.11s**, sys: 0.11s | real: 1.63s, **user: 1.54s**, sys: 0.08s | | ||
- | ^ Test 2 | real: 14.00s, user: 13.62s, **sys: 0.08s** | real: 12.27s, **user: 11.91s**, **sys: 0.04s** | real: 6.17s, user: 6.08s, sys: 0.06s | real: 43.02s, user: 42.72s, sys: 0.09s | real: 1.71s, user: 1.64s, **sys: 0.05s** | | ||
- | ^ Test 3 | real: 14.24s, **user: 14.01s**, sys: 0.14s | real: 12.43s, user: 12.29s, sys: 0.06s | real: 6.14s, **user: 5.98s**, sys: 0.08s | real: 43.15s, user: 42.67s, sys: 0.15s | real: 1.71s, user: 1.65s, sys: 0.06s | | ||
- | ^ Test 4 | **real: 13.94s**, user: 13.62s, **sys: 0.08s** | real: 12.21s, user: 11.93s, sys: 0.11s | real: 6.30s, user: 6.22s, **sys: 0.05s** | real: 43.25s, user: 43.00s, **sys: 0.07s** | real: 1.63s, user: 1.58s, **sys: 0.05s** | | ||
- | ^ Test 5 | real: 14.30s, user: 14.06s, sys: 0.14s | real: 12.24s, user: 12.08s, sys: 0.09s | real: 6.32s, user: 6.19s, sys: 0.08s | real: 31.89s, user: 42.60s, sys: 0.20s | **real: 1.61s**, user: 1.55s, **sys: 0.05s** | ||
- | |||
- | ===== Just For Fun... ===== | ||
- | ...one of my co-workers whipped up this C code which uses '' | ||
==== The Code ==== | ==== The Code ==== | ||
Line 401: | Line 402: | ||
re[i] = pcre_compile(pat[i], | re[i] = pcre_compile(pat[i], | ||
if (!re[i]) { | if (!re[i]) { | ||
- | errx(1, " | + | errx(1, " |
err_offset, pat[i], err_txt); | err_offset, pat[i], err_txt); | ||
} | } | ||
Line 414: | Line 415: | ||
if (match > 0) { | if (match > 0) { | ||
counter++; | counter++; | ||
- | } | + | break; |
- | } | + | |
- | } | + | |
- | + | ||
- | if (!(f = fopen(logfile, | + | |
- | + | ||
- | while ((s = fgets(buf, sizeof(buf), | + | |
- | for (i = 0; pat[i]; i++) { | + | |
- | match = pcre_exec(re[i], | + | |
- | 0, 0, ovec, 30); | + | |
- | if (match > 0) { | + | |
- | counter++; | + | |
} | } | ||
} | } | ||
Line 442: | Line 432: | ||
$ cc -Wall -o pcretest pcretest.c -I/ | $ cc -Wall -o pcretest pcretest.c -I/ | ||
</ | </ | ||
+ | |||
+ | |||
+ | |||
Line 448: | Line 441: | ||
=== The Sun Box === | === The Sun Box === | ||
| ^ Real ^ User ^ Sys ^ | | ^ Real ^ User ^ Sys ^ | ||
- | ^ Test 1 | 7.93s | 7.65s | 0.10s | | + | ^ Test 1 | **6.70s** |
- | ^ Test 2 | 9.46s | 8.54s | 0.10s | | + | ^ Test 2 | 8.03s |
- | ^ Test 3 | 8.28s | 7.55s | 0.09s | | + | ^ Test 3 | 9.04s |
- | ^ Test 4 | 8.09s | 7.65s | 0.06s | | + | ^ Test 4 | |
- | ^ Test 5 | 7.93s | 7.65s | 0.09s | | + | ^ Test 5 | |
+ | |||
+ | === The Laptop === | ||
+ | |||
+ | | ^ Real ^ User ^ Sys ^ | ||
+ | ^ Test 1 | 13.14s | ||
+ | ^ Test 2 | 13.08s | ||
+ | ^ Test 3 | 13.09s | ||
+ | ^ Test 4 | 13.21s | ||
+ | ^ Test 5 | **13.07s** | ||
===== Conclusion ===== | ===== Conclusion ===== | ||
Line 460: | Line 462: | ||
I think that the most amazing thing here is difference in the 2 Perl tests. | I think that the most amazing thing here is difference in the 2 Perl tests. | ||
+ | |||
+ | Though I didn't include it in the // | ||
I think the conclusion that I have to draw from this experiment is that Perl is your best choice, as is often the case, for a simple static regular expression based parser. | I think the conclusion that I have to draw from this experiment is that Perl is your best choice, as is often the case, for a simple static regular expression based parser. | ||
Please, feel free to post to the discussion here in answer to this writeup. | Please, feel free to post to the discussion here in answer to this writeup. |
programming/general/phpvspythonvsperl.1201898835.txt.gz · Last modified: 2008/02/01 20:47 by crustymonkey