Skip to content

Instantly share code, notes, and snippets.

@martinbutt
Created January 14, 2022 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinbutt/629293e2243675ab166ee2049c70e43f to your computer and use it in GitHub Desktop.
Save martinbutt/629293e2243675ab166ee2049c70e43f to your computer and use it in GitHub Desktop.
Phake memory test
<?php
include("vendor/autoload.php");
class ClassWithStaticMethod {
public static function staticMethod(): string
{
return "hello";
}
public function callingStaticWithStaticAccessor(): string
{
return static::staticMethod();
}
}
for ($i=0; $i<10000; $i++) {
$objs[] = \Phake::partialMock(ClassWithStaticMethod::class);
}
echo "Memory allocated: ".memory_get_peak_usage().PHP_EOL;
echo "Memory used: ".memory_get_peak_usage(true).PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment