Hi,
this is the output of profiler showing the bottle neck of a program.
count wall tm cpu time line
14788 0.000000 0.000000 82:sub check_positive{
14788 0.072474 0.260000 83: local $a = 0;
14788 0.072475 0.270000 84: my ($addr) = @_;
14788 0.630970 0.710000 85: tie %hash,
"GDBM_File",$whois_record, &GDBM_WRCREAT, 0644;
11666247 547.4904 679.2700 86: foreach my $cidr (keys %hash){
11666247 595.2517 736.3500 87: my $block = new Net::Netmask($cidr);
11666247 581.9811 698.1900 88: if (($block -> match($addr)) != 0){
14788 28.59408 28.25000 89: return $cidr, $hash{$cidr};
}
so the idea is the following:
I previously form %hash written in GDBM_File. This hash has network
address (for example 170.60.0.0/16) as a key and as value -the network
name. In this subroutine I compare ip address against this network
address to see if ip address match network (with the help of
Net::Netmask module). If it matches I give back the key and value to
main program.
There is 14788 ip addresses for which I am checking. And in the hash
there is around 1519 keys .
Total time in this subroutine at the end is around 1900 sec...around
half an hour, what is a lot!
How can I more efficiently iterate over GDBM file or any idea how to
make it working faster. Will 'while' loop make it faster?
Thank you for any suggestions.
Regards,
Marija
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]