CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
exists() / grep too slow ?



Jul 19, 2001, 12:05 PM

Post #1 of 4 (1066 views)
exists() / grep too slow ? Can't Post

I wrote a little bot and use the NET::IRC module
short description of the code: everytime someone sends a priv msg to the bot = $arg, the bot should check if the msg was sent before (of another user,etc.), so i safe the last 10
msgs in a hash/array (wrote 2 different solutions) to check the new msg if they exist in the hash/array, if not the programm deletes the "oldest" element and makes a new one with the new msg in $arg.

the problem is, it takes too much time for checking the msgs, between the msgs can be get very long sometimes !!


Jul 19, 2001, 11:12 PM

Post #2 of 4 (1054 views)
Re: exists() / grep too slow ? [In reply to] Can't Post

you can get the code at

Enthusiast / Moderator

Jul 20, 2001, 1:24 AM

Post #3 of 4 (1049 views)
Re: exists() / grep too slow ? [In reply to] Can't Post


when you say 'too much time', what periods of time are you talking about?
I've tested a piece of code similar to yours that also implements a message lifo. With 50 different messages, each at a length of 500 characters and up to 10 messages in the lifo, I could do 14000 checks per second on my system (P2/266).
Considering the overhead of the Net::IRC module (which I don't have installed), I'd guess that grep isn't the bottleneck of your application.
FYI, I've also checked some other ways of implementing this using hash tables. These were insignificantly faster on short messages (about 10%), but reasonably slower on longer messages.
Hope this helps.

-- Marcus



Jul 20, 2001, 11:26 PM

Post #4 of 4 (1034 views)
Re: exists() / grep too slow ? [In reply to] Can't Post

wrote now a similar program using Tie::IxHash, between i tested it only on a p 100, need to test it on a faster linuxbox :/


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives