Created
November 29, 2014 00:18
-
-
Save beck24/d2eefe71f78ac7ae5efb to your computer and use it in GitHub Desktop.
ElggBatch performance test
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
<?php | |
require_once __DIR__ . '/engine/start.php'; | |
echo 'tail your log file'; | |
// Ignore user aborts and allow the script to run forever | |
ignore_user_abort(true); | |
session_write_close(); | |
set_time_limit(0); | |
// Tell the browser that we are done | |
header("Connection: close"); | |
$size = ob_get_length(); | |
header("Content-Length: $size"); | |
ob_end_flush(); | |
flush(); | |
elgg_set_ignore_access(); | |
$options = array( | |
'type' => 'group', | |
'subtype' => ELGG_ENTITIES_ANY_VALUE, | |
'limit' => false | |
); | |
$batch_size = 100; | |
$batch = new ElggBatch('elgg_get_entities', $options, null, $batch_size); | |
error_log('starting batch'); | |
$fetch_time_start = time(); | |
$count = 0; | |
$b = 0; | |
foreach ($batch as $e) { | |
$count++; | |
if (($count % $batch_size) == 1) { | |
$b++; | |
$fetch_time = time() - $fetch_time_start; | |
error_log('batch #' . $b . ' fetched in ' . $fetch_time . ' seconds'); | |
error_log('start of new batch'); | |
} | |
if (!($count % $batch_size)) { | |
error_log('end of batch'); | |
$fetch_time_start = time(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment