Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-39443 META: OU Moodle 2.4 performance tuning
  3. MDL-39496

admin_category functions test an array with is_array a lot

    XMLWordPrintable

    Details

      Description

      Inspired by Tim and Sam's work, I've just been having a play with xh_prof.

      I noticed that in admin_category we use $this->category_cache to cache records.

      This is a protected variable, which is set to an array in the constructor, and also in a purge function. The only operations on it are:

      • $this->category_cache = array();
      • isset($this->category_cache[$key])
      • $this->category_cache[$key] = $value;
      • return $this->category_cache[$key];
      • while($this->category_cache)
      • array_pop($this->category_cache);

      In every function which accesses it, we still call is_array($this->category_cache) even though it is only every treated as an array.

      On a default install of Moodle with no additional plugins, the locate() function is called around about 8,600 times with up to two is_array() calls.

      By removing this, I'm seeing savings of around about 100ms on my laptop.

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                14/May/13