diff --git a/perl/exit_strategy.pl b/perl/exit_strategy.pl index 515877315c94ba4cbda9433a45bb02eaf118b95e..12363c2d9843c6969e94e12011911a36bdc42c3b 100644 --- a/perl/exit_strategy.pl +++ b/perl/exit_strategy.pl @@ -642,15 +642,20 @@ sub parse_iexml($filename, $recovery_flag) { # returns count of subdirs of $dir sub searching_relevant_subdirs ($dir) { my $first_two_levels_of_dirs = 0; + my $rx_dir = qr{^\Q$dir\E/?}; ### my $wanted_twolevel_dircount = sub { - my $relpath = $File::Find::name; - $relpath =~ s{^\Q$dir\E/?}{}; - my $depth = File::Spec->splitdir($relpath); + if (/^\.[A-Za-z0-9]/) { # ignore dot-dirs + $File::Find::prune = 1; + } else { + my $relpath = $File::Find::name; + $relpath =~ s{$rx_dir}{}; + my $depth = File::Spec->splitdir($relpath); - $depth >= 2 - and $File::Find::prune = 1; - if (-d $_) {$first_two_levels_of_dirs++;} + $depth >= 2 + and $File::Find::prune = 1; + if (-d $_) {$first_two_levels_of_dirs++;} + } }; ### find($wanted_twolevel_dircount, $dir); @@ -659,6 +664,7 @@ sub searching_relevant_subdirs ($dir) { sub searching_relevant_ie_files ($dir, $tmp_ies_unsorted_file, $first_two_levels_of_dirs) { my $progressbar = Time::Progress->new(min => 0, max => $first_two_levels_of_dirs, smoothing => 1); + my $rx_dir = qr{^\Q$dir\E/?}; ### my $dircount = 0; my $wanted_process_sip = sub { @@ -667,17 +673,21 @@ sub searching_relevant_ie_files ($dir, $tmp_ies_unsorted_file, $first_two_levels my $file = $File::Find::name; # fake name to ue alphabetical sort my $fakeversion = sprintf("%05i", $version); - $file =~ s/V(\d+)-IE/V$fakeversion-IE/; + $file =~ s/V\d+-IE/V$fakeversion-IE/; $tmp_ies_unsorted_file->append($file . "\n"); $dircount++; $File::Find::prune = 1; } elsif (-d) { - my $relpath = $File::Find::name; - $relpath =~ s{^\Q$dir\E/?}{}; - my $depth = File::Spec->splitdir($relpath); - if ($depth <= 2) { - print $progressbar->report("find IE files: %40b ETA: %E \r", $dircount); + if (/^\.[A-Za-z0-9]/) { # ignore dot-dirs + $File::Find::prune = 1; + } else { + my $relpath = $File::Find::name; + $relpath =~ s{$rx_dir}{}; + my $depth = File::Spec->splitdir($relpath); + if ($depth <= 2) { + print $progressbar->report("find IE files: %40b ETA: %E \r", $dircount); + } } } return; @@ -694,9 +704,12 @@ sub searching_ie_files ($dirs_ref, $tmp_ies_unsorted_file) { my $maxpass=scalar @dirs; foreach my $dir (@dirs) { $pass++; + my $begin_time = time; my $first_two_levels_of_dirs = searching_relevant_subdirs($dir); my $count = searching_relevant_ie_files($dir, $tmp_ies_unsorted_file, $first_two_levels_of_dirs); - say "found $count IEs in pass $pass/$maxpass (dir '$dir') "; + my $end_time = time; + my $diff_time = $end_time - $begin_time; + say "found $count IEs in pass $pass/$maxpass (dir '$dir') in $diff_time s "; $cnt_unsorted_files+=$count; } say "\r "; @@ -752,6 +765,9 @@ if (defined $flag_sqldump) { if ($#ARGV_tail < 0) { die "you need at least a directory as argument\n"; } +my $old_stdout = select(STDOUT); +$| = 1; +select($old_stdout); if ( (! defined $flag_continue) @@ -792,7 +808,7 @@ my $dbh = DBI->connect("dbi:SQLite:dbname=$db_filename", "", "", { RaiseError => 1, sqlite_unicode => 1, }) or die "could not connect to database (file '$db_filename')", $DBI::errstr; - +my $begin_time = time; my $plans = prepare_addsql( $dbh); while (<$fh_unsorted_IEs>) { chomp; @@ -816,7 +832,9 @@ while (<$fh_unsorted_IEs>) { } $dbh->disconnect or warn("disconnecting problems, ", $dbh->errstr); -say "\rprocessed $count uniq IEs "; +my $end_time = time; +my $diff_time = $end_time - $begin_time; +say "\rprocessed $count uniq IEs in $diff_time s "; say ""; 1;