Last active
February 11, 2017 05:51
-
-
Save siran/f2a9c1541d5547c1184fbba6bee2bdff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$sourcetable is a table with 58k records