Nice algorithm! The idea of using vectors never occured to me.
I went back and uncomment the print statements to see what kind
of overhead the grep might cause. At N=100000 I end up with:
Benchmark: timing 100 iterations of Ase, Maverick...
Ase: 142 wallclock secs (141.93 usr + 0.04 sys = 141.97 CPU)
Maverick: 166 wallclock secs (166.05 usr + 0.00 sys = 166.05 CPU)
I would have expected us to end up with closer times, but your's ends up
being 24 seconds faster? wow. So, I removed the prints and got:
Benchmark: timing 100 iterations of Ase, Maverick...
Ase: 122 wallclock secs (121.11 usr + 0.00 sys = 121.11 CPU)
Maverick: 164 wallclock secs (164.65 usr + 0.03 sys = 164.68 CPU)
I'm running this on a PII 400, using Red Hat Linux and the
stock perl RPM (5.005_03). It would seem that vec is much
faster under Linux than under windows.
Hmmm...I wonder how these benchmark out on other platforms...
/\/\averick
-
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.
|