Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Comparing two hash tables

by Rajiv (Initiate)
on Mar 28, 2002 at 21:39 UTC ( #155118=perlquestion: print w/ replies, xml ) Need Help??
Rajiv has asked for the wisdom of the Perl Monks concerning the following question:

I am comparing two hash tables that comprise of 5000 elements each so as to get the number of similar keys. The moment i find a match i delete that key from both the hashes. My question is :- Would the performance of my program improve or degrade if i keep deleting the keys?. Please suggest.

Comment on Comparing two hash tables
(Ovid) Re: Comparing two hash tables
by Ovid (Cardinal) on Mar 28, 2002 at 21:45 UTC

    There is no way to answer your question. Sure, if you're working with smaller hashes, maybe your program's performance would improve. Maybe it would degrade, though, depending upon how many buckets the keys would be allocated to (unlikely, but this is just an illustration). That would depend upon the keys. Further, if it takes a longer to delete those keys than the savings you would get from working with a smaller hash, then it's a waste of time. And what about the value of your time? If this program runs once a week for about 30 minutes, is it really worth it?

    In any event, figure out what's important to you and if you think that deleting those keys might help, check out the Benchmark module. It comes standard with Perl.

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

      Thanks for your reply The reason why i am trying to delete the similar keys is that gradually the the search for the next similar would become faster owing to lesser number of keys left. I will also try calculating the time taken using Benchmark module.
        The reason why i am trying to delete the similar keys is that gradually the the search for the next similar would become faster owing to lesser number of keys left
        The time to access a hash member does not depend on the number of keys, but on whether the distribution of the hash keys into the buckets is uniform or not.

        /prakash

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://155118]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2014-09-19 02:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (129 votes), past polls