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:20] – crustymonkey | programming:general:phpvspythonvsperl [2008/04/14 13:55] (current) – crustymonkey | ||
---|---|---|---|
Line 367: | Line 367: | ||
===== 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 399: | 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 412: | 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 440: | Line 432: | ||
$ cc -Wall -o pcretest pcretest.c -I/ | $ cc -Wall -o pcretest pcretest.c -I/ | ||
</ | </ | ||
+ | |||
+ | |||
+ | |||
Line 446: | 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 458: | 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.1201900816.txt.gz · Last modified: 2008/02/01 21:20 by crustymonkey