Author: mcantelon
Date: Wed Jan  4 15:10:10 2012
New Revision: 10557

Log:
Added export timing and timing info to row process.

Modified:
   trunk/lib/QubitFlatfileImport.class.php
   trunk/lib/task/csvImportTask.class.php

Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php     Wed Jan  4 14:19:01 2012        
(r10556)
+++ trunk/lib/QubitFlatfileImport.class.php     Wed Jan  4 15:10:10 2012        
(r10557)
@@ -128,17 +128,37 @@
     return $output;
   }
 
+  protected function startTimer()
+  {
+    $this->timer = new QubitTimer;
+    $this->timer->start();
+  }
+
+  protected function stopTimer()
+  {
+    $this->timer->stop();
+  }
+
+  public function getTimeElapsed()
+  {
+    return $this->timer->elapsed();
+  }
+
   public function csv($fh)
   {
     // inform user of any columns not included in import
     print $this->renderUnhandledColumns();
 
+    $this->startTimer();
+
     // import each row
     while ($item = fgetcsv($fh, 60000))
     {
       print '.';
       $this->row($item);
     }
+
+    $this->stopTimer();
   }
 
   protected function forEachRowColumn($row, $logic)

Modified: trunk/lib/task/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/csvImportTask.class.php      Wed Jan  4 14:19:01 2012        
(r10556)
+++ trunk/lib/task/csvImportTask.class.php      Wed Jan  4 15:10:10 2012        
(r10557)
@@ -335,9 +335,16 @@
         }
         if ($options = $self->getStatus('options'))
         {
-          if ($options['rows-until-update'] && !(($self->getStatus('rows') + 
1) % $options['rows-until-update']))
+          // row count isn't incremented until completion of this closure, so 
add one to reflect reality
+          $rowsProcessed = $self->getStatus('rows') + 1;
+          if ($options['rows-until-update'] && !($rowsProcessed % 
$options['rows-until-update']))
           {
-            print "\n". ($self->getStatus('rows') + 1) ." rows processed.\n";
+            $elapsed = $self->getTimeElapsed();
+            $elapsedMinutes = round($elapsed / 60, 2);
+            $averageTime = round($elapsed / $rowsProcessed, 2);
+
+            print "\n". $rowsProcessed ." rows processed in ". $elapsedMinutes
+              . " minutes (". $averageTime ." second/row average).\n";
           }
         }
       }

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to