--- bin/couchdb2mongodb.pl 2010/01/23 15:06:59 478 +++ bin/couchdb2mongodb.pl 2010/01/23 17:49:07 479 @@ -13,7 +13,7 @@ use File::Path qw(make_path remove_tree); use MongoDB; -my $name = 'pxelator'; +my $name = shift @ARGV || 'pxelator'; my $conn = MongoDB::Connection->new; my $db = $conn->get_database( $name ); @@ -46,7 +46,13 @@ my $total = <$sock>; $total =~ s{^.*total_rows\D+(\d+).+$}{$1}; -warn "# total: $total\n"; + +$|=1; +print "# $name total: $total\n"; + +my $start_t = time(); +my $count = 0; + while(<$sock>) { if ( /"id":"([^"]+)"/ ) { @@ -54,7 +60,10 @@ s/,[\r\n]+$//; # cleanup JSON my $json = from_json( $_ ); $audit->insert( $json->{doc} ); - print STDERR "."; + printf " %d/%d %.2f%% %.2f/s\r", $count, $total + , ( $count / $total ) * 100 + , ( $count / ( time() - $start_t ) ) + if ++$count % 1000 == 0; } else { warn "UNKNOWN: $_"; }