[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/maximebf/debugbar/src/DebugBar/DataCollector/ -> MemoryCollector.php (source)

   1  <?php
   2  /*
   3   * This file is part of the DebugBar package.
   4   *
   5   * (c) 2013 Maxime Bouroumeau-Fuseau
   6   *
   7   * For the full copyright and license information, please view the LICENSE
   8   * file that was distributed with this source code.
   9   */
  10  
  11  namespace DebugBar\DataCollector;
  12  
  13  /**
  14   * Collects info about memory usage
  15   */
  16  class MemoryCollector extends DataCollector implements Renderable
  17  {
  18      protected $realUsage = false;
  19  
  20      protected $peakUsage = 0;
  21  
  22      /**
  23       * Returns whether total allocated memory page size is used instead of actual used memory size
  24       * by the application.  See $real_usage parameter on memory_get_peak_usage for details.
  25       *
  26       * @return bool
  27       */
  28      public function getRealUsage()
  29      {
  30          return $this->realUsage;
  31      }
  32  
  33      /**
  34       * Sets whether total allocated memory page size is used instead of actual used memory size
  35       * by the application.  See $real_usage parameter on memory_get_peak_usage for details.
  36       *
  37       * @param bool $realUsage
  38       */
  39      public function setRealUsage($realUsage)
  40      {
  41          $this->realUsage = $realUsage;
  42      }
  43  
  44      /**
  45       * Returns the peak memory usage
  46       *
  47       * @return integer
  48       */
  49      public function getPeakUsage()
  50      {
  51          return $this->peakUsage;
  52      }
  53  
  54      /**
  55       * Updates the peak memory usage value
  56       */
  57      public function updatePeakUsage()
  58      {
  59          $this->peakUsage = memory_get_peak_usage($this->realUsage);
  60      }
  61  
  62      /**
  63       * @return array
  64       */
  65      public function collect()
  66      {
  67          $this->updatePeakUsage();
  68          return array(
  69              'peak_usage' => $this->peakUsage,
  70              'peak_usage_str' => $this->getDataFormatter()->formatBytes($this->peakUsage, 0)
  71          );
  72      }
  73  
  74      /**
  75       * @return string
  76       */
  77      public function getName()
  78      {
  79          return 'memory';
  80      }
  81  
  82      /**
  83       * @return array
  84       */
  85      public function getWidgets()
  86      {
  87          return array(
  88              "memory" => array(
  89                  "icon" => "cogs",
  90                  "tooltip" => "Memory Usage",
  91                  "map" => "memory.peak_usage_str",
  92                  "default" => "'0B'"
  93              )
  94          );
  95      }
  96  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer