10
10
*/
11
11
namespace Magento \TestFramework \Helper ;
12
12
13
+ /**
14
+ * Integration Test Framework memory management logic.
15
+ */
13
16
class Memory
14
17
{
15
18
/**
@@ -38,21 +41,21 @@ public function __construct(\Magento\Framework\Shell $shell)
38
41
/**
39
42
* Retrieve the effective memory usage of the current process
40
43
*
41
- * memory_get_usage() cannot be used because of the bug
42
- * @link https://bugs.php.net/bug.php?id=62467
44
+ * Function memory_get_usage() cannot be used because of the bug
43
45
*
46
+ * @link https://bugs.php.net/bug.php?id=62467
44
47
* @return int Memory usage in bytes
45
48
*/
46
49
public function getRealMemoryUsage ()
47
50
{
48
51
$ pid = getmypid ();
49
52
try {
53
+ // fall back to the Unix command line
54
+ $ result = $ this ->_getUnixProcessMemoryUsage ($ pid );
55
+ } catch (\Magento \Framework \Exception \LocalizedException $ e ) {
50
56
// try to use the Windows command line
51
57
// some ports of Unix commands on Windows, such as MinGW, have limited capabilities and cannot be used
52
58
$ result = $ this ->_getWinProcessMemoryUsage ($ pid );
53
- } catch (\Magento \Framework \Exception \LocalizedException $ e ) {
54
- // fall back to the Unix command line
55
- $ result = $ this ->_getUnixProcessMemoryUsage ($ pid );
56
59
}
57
60
return $ result ;
58
61
}
@@ -100,9 +103,11 @@ protected function _getWinProcessMemoryUsage($pid)
100
103
* @return int
101
104
* @throws \InvalidArgumentException
102
105
* @throws \OutOfBoundsException
106
+ * phpcs:disable Magento2.Functions.StaticFunction
103
107
*/
104
108
public static function convertToBytes ($ number )
105
109
{
110
+ // phpcs:enable Magento2.Functions.StaticFunction
106
111
if (!preg_match ('/^(.*\d)\h*(\D)$/ ' , $ number , $ matches )) {
107
112
throw new \InvalidArgumentException ("Number format ' {$ number }' is not recognized. " );
108
113
}
@@ -132,12 +137,14 @@ public static function convertToBytes($number)
132
137
* - but the value has only one delimiter, such as "234,56", then it is impossible to know whether it is decimal
133
138
* separator or not. Only knowing the right format would allow this.
134
139
*
135
- * @param $number
140
+ * @param string $number
136
141
* @return string
137
142
* @throws \InvalidArgumentException
143
+ * phpcs:disable Magento2.Functions.StaticFunction
138
144
*/
139
145
protected static function _convertToNumber ($ number )
140
146
{
147
+ // phpcs:enable Magento2.Functions.StaticFunction
141
148
preg_match_all ('/(\D+)/ ' , $ number , $ matches );
142
149
if (count (array_unique ($ matches [0 ])) > 1 ) {
143
150
throw new \InvalidArgumentException (
@@ -152,9 +159,11 @@ protected static function _convertToNumber($number)
152
159
*
153
160
* @link http://php.net/manual/en/function.php-uname.php
154
161
* @return boolean
162
+ * phpcs:disable Magento2.Functions.StaticFunction
155
163
*/
156
164
public static function isMacOs ()
157
165
{
166
+ // phpcs:enable Magento2.Functions.StaticFunction
158
167
return strtoupper (PHP_OS ) === 'DARWIN ' ;
159
168
}
160
169
}
0 commit comments