summaryrefslogtreecommitdiff
path: root/includes/batch.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/batch.inc')
-rw-r--r--includes/batch.inc10
1 files changed, 9 insertions, 1 deletions
diff --git a/includes/batch.inc b/includes/batch.inc
index de47da277..4010acb36 100644
--- a/includes/batch.inc
+++ b/includes/batch.inc
@@ -263,6 +263,8 @@ function _batch_process() {
// If we are in progressive mode, break processing after 1 second.
if ($batch['progressive'] && timer_read('batch_processing') > 1000) {
+ // Record elapsed wall clock time.
+ $current_set['elapsed'] = round((microtime(TRUE) - $current_set['start']) * 1000, 2);
break;
}
}
@@ -289,11 +291,16 @@ function _batch_process() {
$current = $total - $remaining + $finished;
$percentage = $total ? floor($current / $total * 100) : 100;
+ $elapsed = $current_set['elapsed'];
+ // Estimate remaining with percentage in floating format.
+ $estimate = $elapsed * ($total - $current) / $current;
$values = array(
'@remaining' => $remaining,
'@total' => $total,
'@current' => floor($current),
'@percentage' => $percentage,
+ '@elapsed' => format_interval($elapsed / 1000),
+ '@estimate' => format_interval($estimate / 1000),
);
$message = strtr($progress_message, $values);
if (!empty($message)) {
@@ -360,7 +367,8 @@ function _batch_finished() {
include_once DRUPAL_ROOT . '/' . $batch_set['file'];
}
if (function_exists($batch_set['finished'])) {
- $batch_set['finished']($batch_set['success'], $batch_set['results'], $batch_set['operations']);
+ // Format the elapsed time when batch complete.
+ $batch_set['finished']($batch_set['success'], $batch_set['results'], $batch_set['operations'], format_interval($batch_set['elapsed'] / 1000));
}
}
}