My script usually takes 1 minute to run, but with mldbm it takes anywhere from 15 minutes to 1 hour (seems quite long even if it is writing to disk). The script creates 3 db files which grow to about 800kb each.
This is my function to store the HOHs:
sub store{
my ($app,$staffno)=@_;
my $tmp=$appstaffwk{$app};
$tmp->{$staffno}=1;
$appstaffwk{$app}=$tmp;
$tmp=$appstaffmnth{$app};
$tmp->{$staffno}=1;
$appstaffmnth{$app}=$tmp;
$tmp=$appstaffyr{$app};
$tmp->{$staffno}=1;
$appstaffyr{$app}=$tmp;
}
Any ideas how to make this more efficient?
Thanks,
js1.
| [reply] |
I don't think there's any way to speed that up easilly. Every time you assign to one of these hashes, it calls an object method, serialized the data with Storable, and writes it to disk. One thing that matters though is what dbm file you are using. If the individual values are pretty small, you can use SDBM_File, which is the fastest. If they are too big for that, use DB_File.
| [reply] |