This doesn't surprise me in the least. Seeing a speedup of a factor of 200 or so isn't unusual when turning an algorithm from perl to C. Like it or not, perl has a fair number of inefficiencies built into it, and some of the things it requires to happen, like operator overloading and proper tie behaviour, have unavoidable overhead.
C's a lot more limited, and as such can make more assumptions at compile time, which can generate better code, and that's just fine. (Plus, of course, there's been far more work on any C compiler's optimizer than on perl's optimizer, which can make a pretty darned big difference)
Really does look like you did the appropriate thing--used perl for a fast knock-together project, and moved to a faster language when it turned out to be necessary. FWIW, I don't think you'd have seen much, if any, speed win from going with Java. The cost of moving to Java from perl would've been about the same as moving to C, and C's definitely much faster than Java...
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|