Commit 4bd9d493 authored by Nigel Cunningham's avatar Nigel Cunningham
Browse files

(Bug1353802) Remember and reuse last db_format_timestamp output if poss.



This patch adds support for remembering the last parameter used
by ArtefactType::commit to db_format_timestamp and the output of
the function, and reusing the output if the input is the same on
the next call.

In a test import of 2000 users, this patch reduced the number of
invocations of db_format_timestamp from 80,000 (3.6s) to 14,800
(.3s).

Change-Id: I6f5575f9d3649ff53514f9927744a01966d103dd
Signed-off-by: default avatarNigel Cunningham <nigelc@catalyst-au.net>
parent 7441f64a
......@@ -517,6 +517,8 @@ abstract class ArtefactType implements IArtefactType {
* this method, and call parent::commit() in your own function.
*/
public function commit() {
static $last_source, $last_output;
if (empty($this->dirty)) {
return;
}
......@@ -531,7 +533,11 @@ abstract class ArtefactType implements IArtefactType {
foreach (get_object_vars($this) as $k => $v) {
$fordb->{$k} = $v;
if (in_array($k, array('mtime', 'ctime', 'atime')) && !empty($v)) {
$fordb->{$k} = db_format_timestamp($v);
if ($v !== $last_source) {
$last_output = db_format_timestamp($v);
$last_source = $v;
}
$fordb->{$k} = $last_output;
}
}
if (empty($this->id)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment