Definition at line 10 of file MemoryLimit.php.
◆ __construct()
Initialize with the values
- Parameters
-
string | $memCap | |
string | $leakCap | |
\Magento\TestFramework\Helper\Memory | $helper | |
- Exceptions
-
Definition at line 35 of file MemoryLimit.php.
37 $this->_memCap = $memCap ?
$helper->convertToBytes($memCap) : 0;
38 $this->_leakCap = $leakCap ?
$helper->convertToBytes($leakCap) : 0;
◆ printHeader()
Get a header printout
- Returns
- string
Definition at line 47 of file MemoryLimit.php.
49 return PHP_EOL .
'=== Memory Usage System Stats ===' . PHP_EOL;
◆ printStats()
Get statistics printout
- Returns
- string
Definition at line 57 of file MemoryLimit.php.
59 list($usage, $leak) = $this->_getUsage();
63 "Memory usage (OS):\t%s (%.2F%% of %s reported by PHP",
65 100 * $usage / ($usage - $leak),
66 $this->_toMb($usage - $leak)
68 $percentMsg =
'%.2F%% of configured %s limit';
70 $msg .=
', ' . sprintf($percentMsg, 100 * $usage / $this->_memCap, $this->_toMb($this->_memCap));
74 $msg = sprintf(
"Estimated memory leak:\t%s (%.2F%% of used memory", $this->_toMb($leak), 100 * $leak / $usage);
75 if ($this->_leakCap) {
76 $msg .=
', ' . sprintf($percentMsg, 100 * $leak / $this->_leakCap, $this->_toMb($this->_leakCap));
80 return implode(PHP_EOL,
$result) . PHP_EOL;
◆ validateUsage()
Raise error if memory usage breaks configured thresholds
- Returns
- null
- Exceptions
-
Definition at line 100 of file MemoryLimit.php.
102 if (!$this->_memCap && !$this->_leakCap) {
105 list($usage, $leak) = $this->_getUsage();
106 if ($this->_memCap && $usage >= $this->_memCap) {
107 throw new \LogicException(
108 "Memory limit of {$this->_toMb($this->_memCap)} ({$this->_memCap} bytes) has been reached." 111 if ($this->_leakCap && $leak >= $this->_leakCap) {
112 throw new \LogicException(
113 "Estimated memory leak limit of {$this->_toMb( 115 )}" .
" ({$this->_leakCap} bytes) has been reached."
The documentation for this class was generated from the following file:
- vendor/magento/magento2-base/dev/tests/integration/framework/Magento/TestFramework/MemoryLimit.php