On Wed, Jan 22, 2003, Eli Marmor wrote about "Re: news from MySQL":
> > Of course. Use perl. It is perfect for such things and as you probably know
> > has a very strong regexps :-)
>..
> 
> In my original post, I also mentioned the critical need for efficiency.
> 
> Perl (including compiled Perl), not only is not faster than my current

You are absolutely right.

Let me give you a practical example:

Those who have tried Hspell, whose spell-checking program "hspell" is
written in Perl and uses a hash-table to implement dictionary search
(quite similar to what Eli described in his first question) might have
noticed that startup of "hspell", i.e., filling the hash table with
170,000 entries, takes 5 seconds (on my Pentium 500) and the memory
footprint is 17 MB.

Yesterday I sat down and wrote my own dictionary searching algorithm, based
on radix-searching (similar, but different from the patricia trie algorithm
Eli mentioned, because our needs are different). I wrote the code in C.
The resulting code's startup time is 0.1 seconds (50 times faster!) and
memory footprint is about 2 MB.

So, yes, in some applications using special-purpose algorithms does pay
off, big time.

> algorithm (a special state machine), but is much slower. In addition,

Kernigan and Pike in their relatively-new book "The Practice of programming"
give an example very similar to yours, as an example of choosing good
algorithms. Their example involves a spam filter, which takes a given
message and needs to check whether a large number of patterns matches
this text. They demonstrate how the naive implementation (checking the
patterns one by one against the message) is probably the worst approach to
solving this problem.


-- 
Nadav Har'El                        |   Wednesday, Jan 22 2003, 19 Shevat 5763
[EMAIL PROTECTED]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Energizer Bunny arrested - charged with
http://nadav.harel.org.il           |battery.

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to