public function Tester::runGenerate in Simple XML sitemap 8.3
Same name and namespace in other branches
- 4.x tests/scripts/performance_test.php \Tester::runGenerate()
File
- tests/
scripts/ performance_test.php, line 91
Class
Code
public function runGenerate($count_queries = FALSE) {
$batch = new BatchBuilder();
$relative_path_to_script = (new Filesystem())
->makePathRelative(__DIR__, \Drupal::root()) . basename(__FILE__);
$batch
->setFile($relative_path_to_script);
$batch
->addOperation(__CLASS__ . '::' . 'doBatchGenerateSitemap', [
$count_queries,
]);
$batch
->setFinishCallback([
BatchTrait::class,
'finishGeneration',
]);
// Start drush batch process.
batch_set($batch
->toArray());
// See https://www.drupal.org/node/638712
$batch =& batch_get();
$batch['progressive'] = FALSE;
$timer = 'simple_sitemap:perf_test:' . $this->timerKey++;
Timer::start($timer);
drush_backend_batch_process();
$time = round(Timer::stop($timer)['time'] / 1000, 2) . ' seconds';
$this->logger
->info('Generation completed in: ' . $time);
// Remove the batch as Drush doesn't appear to properly clean up on success.
$batch =& batch_get();
$batch = NULL;
}