Skip to content

Commit

Permalink
Add min miliseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
Lloople committed Jan 8, 2020
1 parent 1b93c39 commit 96bb295
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/Runners/SlowestTests/Channel.php
Expand Up @@ -7,21 +7,45 @@

abstract class Channel implements AfterTestHook, AfterLastTestHook
{
/**
* Tests marked as slow.
*
* @var array
*/
protected $tests = [];

/**
* The max number of rows to be reported.
*
* @var int|null
*/
protected $rows;

public function __construct(?int $rows = null)
/**
* The minimum amount of miliseconds to consider a test slow.
*
* @var int|null
*/
protected $min;

public function __construct(?int $rows = null, ?int $min = 200)
{
$this->rows = $rows;
$this->min = $min;
}

public function executeAfterTest(string $test, float $time): void
{
$this->tests[$test] = $this->timeToMiliseconds($time);
$time = $this->timeToMiliseconds($time);

if ($time <= $this->min) {
return;
}

$this->tests[$test] = $time;
}

protected function timeToMiliseconds(float $time)
protected function timeToMiliseconds(float $time): int
{
return (int)($time * 1000);
}
Expand Down

0 comments on commit 96bb295

Please sign in to comment.