[LON-CAPA-cvs] cvs: loncom /debugging_tools db_copy.pl

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 13 Oct 2006 21:00:06 -0000


albertel		Fri Oct 13 17:00:06 2006 EDT

  Modified files:              
    /loncom/debugging_tools	db_copy.pl 
  Log:
  - track skipped files
  - update to use the correct creat db by default
  
  
Index: loncom/debugging_tools/db_copy.pl
diff -u loncom/debugging_tools/db_copy.pl:1.4 loncom/debugging_tools/db_copy.pl:1.5
--- loncom/debugging_tools/db_copy.pl:1.4	Fri Oct 13 14:34:07 2006
+++ loncom/debugging_tools/db_copy.pl	Fri Oct 13 17:00:06 2006
@@ -8,10 +8,10 @@
 use File::Find;
 use LONCAPA;
 use LONCAPA::Configuration;
-use Cwd;
+use Fcntl qw(:flock);
 
 my $dump_db = '/home/httpd/perl/debug/dump_db_static_32';
-my $create_db = '/home/httpd/perl/debug/create_db_dynamic';
+my $create_db = '/home/httpd/perl/debug/create_db_dynamic_64';
 if (!-x $dump_db || !-x $create_db) {
     print("Unable to run needed helper programs\n $dump_db\n $create_db\n.");
     exit(-1);
@@ -46,6 +46,7 @@
 }
 
 my $done=0;
+my $skip=0;
 my $starttime;
 my $last_100_start_time;
 sub process_db {
@@ -59,6 +60,9 @@
 	rename($file,"$file.old");
 	rename("$file.new","$file");
 	&unlock_db($dbref);
+    } else {
+	#print("skip $_\n");
+	$skip++;
     }
     $done++;
     if (!($done %100)) {
@@ -66,10 +70,10 @@
         my $took = time()-$starttime;
         my $togo = int(($took/$done) * ($count-$done));
         my $total = $togo+$took;
-        my $per = $took/$done;
+	my $per = ($done-$skip)?$took/($done-$skip):0;
         my $last_per = (time()-$last_100_start_time)/100;
-        printf("%6d in %6d, togo %6d, overall %6d, %.4f (for one), %.4f)\n",
-	       $done,$took,$togo,$total,$per,$last_per);
+        printf("%6d (%6d) in %6d, togo %6d, overall %6d, %.3f (each), %.3f\n",
+	       $done,$skip,$took,$togo,$total,$per,$last_per);
         $last_100_start_time = time();
     }
 }