Created
September 6, 2012 11:04
-
-
Save edorian/3654855 to your computer and use it in GitHub Desktop.
PHPUnit memory test listener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
phpunit.xml.dist: | |
<listeners> | |
<listener class="MemoryTestListener" file="./MemoryTestListener.php"> | |
</listeners> | |
In the same folder: MemoryTestListener.php | |
<?php | |
class MemoryTestListener implements PHPUnit_Framework_TestListener | |
{ | |
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) {} | |
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) {} | |
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) {} | |
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) {} | |
public function startTest(PHPUnit_Framework_Test $test) {} | |
public function endTest(PHPUnit_Framework_Test $test, $time) | |
{ | |
var_dump(round(memory_get_peak_usage() / 1024 / 1024)); | |
} | |
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {} | |
public function endTestSuite(PHPUnit_Framework_TestSuite $suite) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment