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 21:06] – 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 357: | Line 357: | ||
==== The Laptop ==== | ==== The Laptop ==== | ||
- | | ^ PHP ^ Python (non-compiled) ^ Python (compiled) ^ Perl (interpolated string loop) ^ Perl (hard coded regexes) ^ | + | | ^ PHP ^^^ Python (non-compiled) |
- | ^ 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 | | + | | | **Real** |
- | ^ 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 1 | 14.25s |
- | ^ 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 2 | 14.00s |
- | ^ 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 3 | 14.24s |
- | ^ 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** | | + | ^ Test 4 | **13.94s** |
+ | ^ Test 5 | 14.30s | ||
===== Just For Fun... ===== | ===== Just For Fun... ===== | ||
...one of my co-workers whipped up this C code which uses '' | ...one of my co-workers whipped up this C code which uses '' | ||
+ | |||
+ | |||
+ | |||
==== The Code ==== | ==== The Code ==== | ||
Line 398: | 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 411: | 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 439: | Line 432: | ||
$ cc -Wall -o pcretest pcretest.c -I/ | $ cc -Wall -o pcretest pcretest.c -I/ | ||
</ | </ | ||
+ | |||
+ | |||
+ | |||
Line 445: | 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 457: | 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.1201900000.txt.gz · Last modified: 2008/02/01 21:06 by crustymonkey