use Time::HiRes qw(time); use vars qw($then); sub timepart { my($partname)=@_; my $now = time; if ($partname) { $time{$partname} += $now - $then; } $then = $now; } timepart(); foreach my $line (@FILE) { timepart('loop'); if (($dot % 1000) == 0) { print STDERR "."; } timepart('mod'); $line=~/^(\S*) [0-9.]* (.*)$/o; my ($class, $feature_vector) = ($1, $2); timepart('regex'); my %case; $case{'class'}=$class; timepart('createcase'); foreach my $feature (split /\s+/, $feature_vector) { $case{'fv'}{$feature}=1; } timepart('feature'); push @cases, \%case; timepart('pushcase'); $dot++; } print "\n"; while(my($k,$v)=each(%time)) { printf "%10s: %10.6f\n",$k,$v; } #### for $i in (1..2_000_000) { my %case; push(@r,\%case); }