[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Speed question



Hi all!
I was playing around with DBM module with something like:
#######################
#! perl -w

use strict;
use DB_File;

my %database;
my $db = tie %database, 'DB_File', "simpledb.dat" or die "Non posso
inizializzare il database: $!\n";

my $fd = $db->fd();
open DATAFILE, "+<&=$fd" or die "Non posso aprire il database: $!\n";
open DUMP, (">dataDump") or die "Non posso aprire il file di dump: $!";


for ( my $i = 1; $i < 4000; $i++) {  # <---------
  $database{"riga$i"} = "un po di testo: $i";
  }
undef $db;
untie %database;
close DATAFILE or die "Non posso chiudere il filehandle: $!\n";


$db = tie %database, 'DB_File', "simpledb.dat" or die "Non posso
inizializzare il database: $!\n";

$fd = $db->fd();
open DATAFILE, "+<&=$fd" or die "Non posso aprire il database: $!\n";

foreach my $key (keys %database ) {
  print DUMP "$key\n". ("=" x (length($key)+1))."\n";
  print DUMP "$database{$key}\n\n";
}

undef $db;
untie %database;
close DATAFILE or die "Non posso chiudere il filehandle: $!\n";
close DUMP or die "Non posso chiudere il file di dump: $!\n";



exit;
################

*but*: until the 'for' is below 4000 iterations, the script finish in 2
seconds, more or less; if I repeat the loop 5000 times I have to wait 30
secs!
Am I missing something ( as usual)?
I'm using an iBook with 96 MB RAM (MacPerl eats constantly 2 Megs out of
14...)
TIA

--
Giorgio Valoti

MagneticMedia Network

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org