At 9:58 AM +0800 12/2/09, =?GB2312?B?T3JjaGlkIEZhaXJ5ICjAvLuoz8nX0yk=?= wrote:
Hello,

Maybe it's not so suitable to ask this here.
But is there a good way (code sample?) to implement a speed test
between Perl and C?
For a project which handles lots of data we want to know how slower
perl is than C.

That is a suitable question, but there may not be a good answer. It all depends upon what you want your program to do. In general, a C program will out-perform a Perl program. However, if you are reading a lot of data from files, the I/O time will dominate, and there may not be much difference. Ditto for programs that read or write data over a network. If your program does a lot of arithmetic, then C will probably be faster. I recently compared a math problem with lots of sines and cosines, and a Perl version was about half the speed of a C version.

You should also consider the "speed" of the programmer. I can write a Perl program in less than half the time it would take me to write the same program in C, C++, or Java. You will have to invest more programming time for the C version than you would for the Perl version. This is particularly true if your program involves the manipulation of text, rather than numbers, a job for which Perl is well-suited.

The best answer to your question would be to write a simple version of your program in both languages and compare. You can also look for published benchmarks, but consider whether or not these benchmarks are measuring the type of processing you want to do. Here are a couple:

<http://www.bioinformatics.org/benchmark/results.html>
<http://dan.corlan.net/bench.html>

You can no doubt find more.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to