You are here

function drush_migrate_print_memory in Migrate 6.2

Same name and namespace in other branches
  1. 7.2 migrate.drush.inc \drush_migrate_print_memory()
2 calls to drush_migrate_print_memory()
drush_migrate_import in ./migrate.drush.inc
Perform import on one or more migrations.
drush_migrate_rollback in ./migrate.drush.inc
Roll back one specified migration

File

./migrate.drush.inc, line 1298
Drush support for the migrate module

Code

function drush_migrate_print_memory() {
  global $_migrate_memory;
  $temparray = array();
  foreach ((array) $_migrate_memory as $name => $memoryrec) {

    // We have to use timer_read() for active timers, and check the record for others
    if (isset($memoryrec['start'])) {
      $temparray[$name] = migrate_memory_read($name);
    }
    else {
      $temparray[$name] = $memoryrec['bytes'];
    }
  }

  // Go no farther if there were no timers
  if (count($temparray) > 0) {

    // Put the highest cumulative times first
    arsort($temparray);
    $table = array();
    $table[] = array(
      'Name',
      'Cum (bytes)',
      'Count',
      'Avg (bytes)',
    );
    foreach ($temparray as $name => $memory) {
      $count = $_migrate_memory[$name]['count'];
      if ($count > 0) {
        $avg = round($memory / $count, 0);
      }
      else {
        $avg = 'N/A';
      }
      $table[] = array(
        $name,
        $memory,
        $count,
        $avg,
      );
    }
    drush_print_table($table, TRUE);
  }
}