Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23956a2
commit 92f3bc9
Showing
6 changed files
with
172 additions
and
18 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace mre\PHPench\Aggregator; | ||
use mre\PHPench\AggregatorInterface; | ||
|
||
/** | ||
* The average of the data will be calculated | ||
* | ||
* @author Markus Poerschke <markus@eluceo.de> | ||
*/ | ||
class AverageAggregator implements AggregatorInterface | ||
{ | ||
private $data = []; | ||
|
||
public function push($i, $index, $value) | ||
{ | ||
if (!isset($this->data[$i][$index])) | ||
{ | ||
$this->data[$i][$index] = $value; | ||
|
||
return; | ||
} | ||
|
||
$this->data[$i][$index] += $value; | ||
$this->data[$i][$index] /= 2; | ||
} | ||
|
||
public function getData() | ||
{ | ||
return $this->data; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace mre\PHPench\Aggregator; | ||
|
||
use mre\PHPench\AggregatorInterface; | ||
|
||
/** | ||
* Simple aggregator that will simply replace the data | ||
* | ||
* @author Markus Poerschke <markus@eluceo.de> | ||
*/ | ||
class SimpleAggregator implements AggregatorInterface | ||
{ | ||
private $data = []; | ||
|
||
public function push($i, $index, $value) | ||
{ | ||
$this->data[$i][$index] = $value; | ||
} | ||
|
||
public function getData() | ||
{ | ||
return $this->data; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace mre\PHPench; | ||
|
||
/** | ||
* Aggregates the data from the test results | ||
* | ||
* @author Markus Poerschke <markus@eluceo.de> | ||
*/ | ||
interface AggregatorInterface | ||
{ | ||
/** | ||
* Adds a new value to the aggregator | ||
* | ||
* @param $i | ||
* @param $index | ||
* @param $value | ||
*/ | ||
public function push($i, $index, $value); | ||
|
||
/** | ||
* Returns the aggregated data as an array. | ||
* | ||
* array( | ||
* run_1 => array (TEST_1 => 123, TEST_2 => 456, ...) | ||
* ... | ||
* ) | ||
* | ||
* @return array | ||
*/ | ||
public function getData(); | ||
} |