Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
Removing workaround for polyfractal/athletic#13, since it's fixed in …
Browse files Browse the repository at this point in the history
…`0.1.7`
  • Loading branch information
Ocramius committed Nov 11, 2013
1 parent 94115ba commit 4af4f0f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 142 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"phpmd/phpmd": "1.5.*",
"squizlabs/php_codesniffer": "1.4.*",
"satooshi/php-coveralls": "~0.6",
"athletic/athletic": "~0.1.6"
"athletic/athletic": "~0.1.7"
},
"autoload": {
"psr-0": {
Expand Down
141 changes: 0 additions & 141 deletions tests/LazyMapPerformance/NullLazyMapEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@
*/
class NullLazyMapEvent extends AthleticEvent
{
/**
* @todo to be removed: depends on {@link https://github.com/polyfractal/athletic/issues/13}
*
* @var \Athletic\Factories\MethodResultsFactory
*/
private $methodResultsFactory;

/**
* @var mixed[]
*/
Expand Down Expand Up @@ -135,138 +128,4 @@ public function unInitializedLazyMapPerformance()
{
return $this->lazyMap->nonExistingKey;
}

/**
* @todo to be removed: depends on {@link https://github.com/polyfractal/athletic/issues/13}
*
* @param \Athletic\Factories\MethodResultsFactory $methodResultsFactory
*/
public function setMethodFactory($methodResultsFactory)
{
$this->methodResultsFactory = $methodResultsFactory;
}

/**
* @todo to be removed: depends on {@link https://github.com/polyfractal/athletic/issues/13}
*
* @return \Athletic\Results\MethodResults[]
*/
public function run()
{
$classReflector = new \ReflectionClass(get_class($this));

$methodAnnotations = array();
foreach ($classReflector->getMethods() as $methodReflector) {
$methodAnnotations[$methodReflector->getName()] = new \zpt\anno\Annotations($methodReflector);
}

$this->classSetUp();
$results = $this->runBenchmarks($methodAnnotations);
$this->classTearDown();

return $results;
}

/**
* @todo to be removed: depends on {@link https://github.com/polyfractal/athletic/issues/13}
*
* @param \zpt\anno\Annotations[] $methods
*
* @return \Athletic\Results\MethodResults[]
*/
private function runBenchmarks($methods)
{
$results = array();

foreach ($methods as $methodName => $annotations) {
if (isset($annotations['iterations']) === true) {
$results[] = $this->runMethodBenchmark($methodName, $annotations);
$this->tearDown();
}
}
return $results;
}

/**
* @todo to be removed: depends on {@link https://github.com/polyfractal/athletic/issues/13}
*
* @param string $method
* @param int $annotations
*
* @return \Athletic\Results\MethodResults
*/
private function runMethodBenchmark($method, $annotations)
{
$iterations = $annotations['iterations'];
$avgCalibration = $this->getCalibrationTime($iterations);

$results = array();
for ($i = 0; $i < $iterations; ++$i) {
$this->setUp();
$results[$i] = $this->timeMethod($method) - $avgCalibration;
}

$finalResults = $this->methodResultsFactory->create($method, $results, $iterations);

$this->setOptionalAnnotations($finalResults, $annotations);

return $finalResults;

}

/**
* @todo to be removed: depends on {@link https://github.com/polyfractal/athletic/issues/13}
*
* @param string $method
*
* @return mixed
*/
private function timeMethod($method)
{
$start = microtime(true);
$this->$method();
return microtime(true) - $start;
}

/**
* @todo to be removed: depends on {@link https://github.com/polyfractal/athletic/issues/13}
*
* @param int $iterations
*
* @return float
*/
private function getCalibrationTime($iterations)
{
$emptyCalibrationMethod = 'emptyCalibrationMethod';
$resultsCalibration = array();
for ($i = 0; $i < $iterations; ++$i) {
$resultsCalibration[$i] = $this->timeMethod($emptyCalibrationMethod);
}
return array_sum($resultsCalibration) / count($resultsCalibration);
}

/**
* @todo to be removed: depends on {@link https://github.com/polyfractal/athletic/issues/13}
*/
private function emptyCalibrationMethod()
{

}

/**
* @todo to be removed: depends on {@link https://github.com/polyfractal/athletic/issues/13}
*
* @param \Athletic\Results\MethodResults $finalResults
* @param array $annotations
*/
private function setOptionalAnnotations(\Athletic\Results\MethodResults $finalResults, $annotations)
{
if (isset($annotations['group']) === true) {
$finalResults->setGroup($annotations['group']);
}

if (isset($annotations['baseline']) === true) {
$finalResults->setBaseline();
}
}
}

0 comments on commit 4af4f0f

Please sign in to comment.