我只想通过WebTestCase
方法跟踪我测试的请求所使用的全部内存量。
WebTestCase::testReturnValidUser
方法中的类似内容:
$client = static::createClient();
$client->enableProfiler();
$crawler = $client->request(
'GET',
$userURL
);
...
if ($profile = $client->getProfile()) {
$this->assertLessThan(10, $profile->getSomethingForMemoryConsumption())
}
旁注:遗憾的是,我无法安装xhproof
。 Brew似乎没有为我自己安装的php7提供xhproof。
答案 0 :(得分:2)
好的我找到了:我可以简单地使用已存在的MemoryDataCollector而不定义我自己的DataCollector
:
if ($profile = $client->getProfile()) {
$this->assertLessThan(30000000, $profile->getCollector('memory')->getMemory());
}