@@ -183,9 +183,9 @@ public function getDynamicSchemaExample()
183
183
*
184
184
* @param int $iterations
185
185
*
186
- * @return mixed
186
+ * @return array
187
187
*/
188
- public function runPerformanceTestForSmallNestedResources ($ iterations )
188
+ public function runPerformanceTestForSmallNestedResources (int $ iterations ): array
189
189
{
190
190
$ closure = function () use ($ iterations ) {
191
191
$ options = new EncodingParameters (
@@ -217,20 +217,21 @@ public function runPerformanceTestForSmallNestedResources($iterations)
217
217
}
218
218
};
219
219
220
- $ timeSpent = null ;
221
- $ this ->getTime ($ closure , $ timeSpent );
220
+ $ timeSpent = 0 ;
221
+ $ bytesUsed = 0 ;
222
+ $ this ->getTime ($ closure , $ timeSpent , $ bytesUsed );
222
223
223
- return $ timeSpent ;
224
+ return [ $ timeSpent, $ bytesUsed ] ;
224
225
}
225
226
226
227
/**
227
228
* Run performance test one time for big collection of resources.
228
229
*
229
230
* @param int $numberOfItems
230
231
*
231
- * @return mixed
232
+ * @return array
232
233
*/
233
- public function runPerformanceTestForBigCollection ($ numberOfItems )
234
+ public function runPerformanceTestForBigCollection (int $ numberOfItems ): array
234
235
{
235
236
$ closure = function () use ($ numberOfItems ) {
236
237
$ sites = [];
@@ -262,26 +263,32 @@ public function runPerformanceTestForBigCollection($numberOfItems)
262
263
$ encoder ->encodeData ($ sites , $ options );
263
264
};
264
265
265
- $ timeSpent = null ;
266
- $ this ->getTime ($ closure , $ timeSpent );
266
+ $ timeSpent = 0 ;
267
+ $ bytesUsed = 0 ;
268
+ $ this ->getTime ($ closure , $ timeSpent , $ bytesUsed );
267
269
268
- return $ timeSpent ;
270
+ return [ $ timeSpent, $ bytesUsed ] ;
269
271
}
270
272
271
273
/**
272
274
* @param Closure $closure
273
275
* @param float &$time
276
+ * @param int &$memory
274
277
*
275
278
* @return mixed
276
279
*/
277
- private function getTime (Closure $ closure , &$ time )
280
+ private function getTime (Closure $ closure , float &$ time, int & $ memory )
278
281
{
279
- $ time_start = microtime (true );
282
+ $ timeStart = microtime (true );
283
+ $ bytesStart = memory_get_usage ();
280
284
try {
281
285
return $ closure ();
282
286
} finally {
283
- $ time_end = microtime (true );
284
- $ time = $ time_end - $ time_start ;
287
+ $ bytesEnd = memory_get_usage ();
288
+ $ timeEnd = microtime (true );
289
+
290
+ $ time = $ timeEnd - $ timeStart ;
291
+ $ memory = $ bytesEnd - $ bytesStart ;
285
292
}
286
293
}
287
294
}
0 commit comments