--- trunk/scripts/estcp.pl 2006/01/16 23:08:07 80 +++ trunk/scripts/estcp.pl 2006/01/17 00:17:50 82 @@ -3,6 +3,8 @@ use strict; use Search::Estraier; use URI::Escape qw/uri_escape/; +use Time::HiRes; +use POSIX qw/strftime/; =head1 NAME @@ -30,12 +32,13 @@ print "Copy from ",$from_n->name," (",$from_n->label,") to ",$to_n->name," (",$to_n->label,") - ",$from_n->doc_num," documents (",$from_n->word_num," words, ",$from_n->size," bytes)\n"; -my $tick = int($from_n->doc_num / 78); +my $doc_num = $from_n->doc_num || 1; -print "["; my $res; my $prev; -my $i = 0; +my $i = 1; + +my $t = time(); do { $from_n->shuttle_url( $from_n->{url} . '/list', @@ -47,9 +50,17 @@ foreach my $l (split(/\n/,$res)) { (my $id, $prev) = split(/\t/,$l, 2); $to_n->put_doc( $from_n->get_doc( $id )); + $i++; } - print "$prev\n"; - print "." if ($i++ % $tick == 0); + warn "$prev\n"; + + my $rate = ( $i / (time() - $t) ); + printf("%d records, %1.2f%% [%1.2f rec/s] estimated finish: %s\n", + $i, + ($i * 100 / $doc_num), + $rate, + strftime("%Y-%m-%d %H:%M:%S", localtime( time() + int(($doc_num-$i) / $rate))), + ); + } while ($res); -print "]\n";