Skip to content

Instantly share code, notes, and snippets.

@siran
Last active February 11, 2017 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siran/f2a9c1541d5547c1184fbba6bee2bdff to your computer and use it in GitHub Desktop.
Save siran/f2a9c1541d5547c1184fbba6bee2bdff to your computer and use it in GitHub Desktop.
$registros = $source_table->find()->order('id');
$inicio = time();
$diff = time();
foreach ($registros as $registro) {
//for ($n = 0; $n < 500000; $n++) { //<-------------- see the difference when iterating over a for(0..500k) than over a foreach($registros)
$num++;
if ($num % 100 == 0) {
$memoria_usada = number_format(memory_get_usage(true), 0);
$to_log = __("used memory: ".$memoria_usada."\t$num records processed (time ".(time() - $inicio)."; diff: ".(time() - $diff).")");
Log::info($to_log,'memory');
$diff = time();
}
}
@siran
Copy link
Author

siran commented Feb 11, 2017

$sourcetable is a table with 58k records

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment