Commit 6bc4db12 authored by Nigel Cunningham's avatar Nigel Cunningham Committed by Gerrit Code Review

(Bug1364703) Add caching to ArtefactType::get_plugin_name

Add caching of results to ArtefactType::get_plugin_name.
In a test export of 1000 users via admin/users/bulkexport.php,
this patch reduced the number of calls to get_field from 78,000
to 26 and reduced the execution time from 115 seconds to 92 seconds.

Change-Id: Ie7b2e39089bed1c3cd4844748b21f1ffb251f8dd
Signed-off-by: default avatarNigel Cunningham <nigelc@catalyst-au.net>
parent 5cdd1f45
...@@ -438,7 +438,14 @@ abstract class ArtefactType implements IArtefactType { ...@@ -438,7 +438,14 @@ abstract class ArtefactType implements IArtefactType {
} }
public function get_plugin_name() { public function get_plugin_name() {
return get_field('artefact_installed_type', 'plugin', 'name', $this->get('artefacttype')); static $cache = array();
$type = $this->get('artefacttype');
if (!isset($cache[$type])) {
$cache[$type] = get_field('artefact_installed_type', 'plugin', 'name', $type);
}
return $cache[$type];
} }
/** /**
......
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