Unless the hashes are very big, I'd agree the problem is likely
elsewhere. The
Perl code profiler might shed some light on the bottlenecks:
   
   perldoc Devel:Dprof   (available with Perl..  5.6.1 or later..maybe
earlier)

If the code doesn't profile easily, you might just benchmark creation
time for
similarly sized hashes for a seat-of-the-pants feel. 

On my busy server, for instance,  a 50K hash consistently takes under a
second to 
generate:

     my %hash = map { ($_, rand $_ ) } 1..50_000;

A 50K array takes under a third of the time:

     my @array; $array[$_] = rand $_ for 1..50_000;

This is very simplistic but still you can get clues about when size
starts to
stretch completion times.



Hth,
--
Charles DeRykus   
     

-----Original Message-----
From: Haufler, Wayne A 
Sent: Thursday, December 15, 2005 8:55 AM
To: [email protected]
Cc: Haufler, Wayne A
Subject: Hash Performance

One of my roles in a Tools Development group at Boeing is to help
maintain existing Perl programs and to champion the use of Perl in
future development.

One of the developers here has the impression /opinion that Perl Hashes
are slow.  That was because of the poor performance of the GUI menu of a
particular Perl tool, but I believe the poor performance is due to other
factors.  May be able to prove that later.

I have browsed through my extensive collection of O'Reilly Perl books,
and websites, but can't seem to find anything to support my contention
that hashes are very efficient, almost as much as arrays, and shouldn't
be avoided.

Am I right?  Can anyone point me to supporting material?
(I couldn't find any perl-performance related mailing list)

I hope to include that in a Perl class I will be teaching to my group
early next year.

Thank you,
Wayne Haufler

Senior Software Engineer (SE)
In Space Shuttle Program (SSP)
Backup Flight System (BFS) Tools Group
Boeing, NASA Systems, Houston
E-mail: [EMAIL PROTECTED]
Skills    :  Perl,Unix,C,C++,SQL,QNX,X-Windows  

(Disclaimer: The comments and opinions expressed are my own and do not
represent the view of  Boeing, United Space Alliance, JSC, or NASA.)


Reply via email to