generated from pestphp/pest-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
6b46023
commit 73637ad
Showing
25 changed files
with
1,398 additions
and
357 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,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pest\Stressless\Blocks; | ||
|
||
use Pest\Stressless\Contracts\Block; | ||
use Pest\Stressless\ValueObjects\Result; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final readonly class NetworkDuration implements Block | ||
{ | ||
/** | ||
* Creates a block instance. | ||
*/ | ||
public function __construct( | ||
private Result $result, | ||
) { | ||
// | ||
} | ||
|
||
/** | ||
* Gets the block label. | ||
*/ | ||
public function value(): string | ||
{ | ||
$array = $this->result->toArray(); | ||
|
||
$duration = $array['metrics']['http_req_connecting']['values']['avg'] | ||
+ $array['metrics']['http_req_tls_handshaking']['values']['avg'] | ||
+ $array['metrics']['http_req_duration']['values']['avg'] | ||
- $array['metrics']['http_req_waiting']['values']['avg']; | ||
|
||
return sprintf('%4.2f ms', $duration); | ||
} | ||
|
||
/** | ||
* Gets the block color. | ||
*/ | ||
public function color(): string | ||
{ | ||
$array = $this->result->toArray(); | ||
|
||
$duration = $array['metrics']['http_req_connecting']['values']['avg'] | ||
+ $array['metrics']['http_req_tls_handshaking']['values']['avg'] | ||
+ $array['metrics']['http_req_duration']['values']['avg'] | ||
- $array['metrics']['http_req_waiting']['values']['avg']; | ||
|
||
return match (true) { | ||
$duration < 100 => 'green', | ||
$duration < 200 => 'yellow', | ||
default => 'red', | ||
}; | ||
} | ||
} |
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,55 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pest\Stressless\Blocks; | ||
|
||
use Pest\Stressless\Contracts\Block; | ||
use Pest\Stressless\ValueObjects\Result; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final readonly class ResponseDuration implements Block | ||
{ | ||
/** | ||
* Creates a block instance. | ||
*/ | ||
public function __construct( | ||
private Result $result, | ||
) { | ||
// | ||
} | ||
|
||
/** | ||
* Gets the block label. | ||
*/ | ||
public function value(): string | ||
{ | ||
$array = $this->result->toArray(); | ||
|
||
$duration = $array['metrics']['req_connecting']['values']['avg'] | ||
+ $array['metrics']['req_tls_handshaking']['values']['avg'] | ||
+ $array['metrics']['req_duration']['values']['avg']; | ||
|
||
return sprintf('%4.2f ms', $duration); | ||
} | ||
|
||
/** | ||
* Gets the block color. | ||
*/ | ||
public function color(): string | ||
{ | ||
$array = $this->result->toArray(); | ||
|
||
$duration = $array['metrics']['req_connecting']['values']['avg'] | ||
+ $array['metrics']['req_tls_handshaking']['values']['avg'] | ||
+ $array['metrics']['req_duration']['values']['avg']; | ||
|
||
return match (true) { | ||
$duration < 200 => 'green', | ||
$duration < 400 => 'yellow', | ||
default => 'red', | ||
}; | ||
} | ||
} |
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,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pest\Stressless\Blocks; | ||
|
||
use Pest\Stressless\Contracts\Block; | ||
use Pest\Stressless\ValueObjects\Result; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final readonly class ServerDuration implements Block | ||
{ | ||
/** | ||
* Creates a block instance. | ||
*/ | ||
public function __construct( | ||
private Result $result, | ||
) { | ||
// | ||
} | ||
|
||
/** | ||
* Gets the block label. | ||
*/ | ||
public function value(): string | ||
{ | ||
$array = $this->result->toArray(); | ||
|
||
$duration = $array['metrics']['http_req_waiting']['values']['avg']; | ||
|
||
return sprintf('%4.2f ms', $duration); | ||
} | ||
|
||
/** | ||
* Gets the block color. | ||
*/ | ||
public function color(): string | ||
{ | ||
$array = $this->result->toArray(); | ||
|
||
$duration = $array['metrics']['http_req_waiting']['values']['avg']; | ||
|
||
return match (true) { | ||
$duration < 100 => 'green', | ||
$duration < 200 => 'yellow', | ||
default => 'red', | ||
}; | ||
} | ||
} |
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,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pest\Stressless\Blocks; | ||
|
||
use Pest\Stressless\Contracts\Block; | ||
use Pest\Stressless\ValueObjects\Result; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final readonly class SuccessRate implements Block | ||
{ | ||
/** | ||
* Creates a block instance. | ||
*/ | ||
public function __construct( | ||
private Result $result, | ||
) { | ||
// | ||
} | ||
|
||
/** | ||
* Gets the block label. | ||
*/ | ||
public function value(): string | ||
{ | ||
$array = $this->result->toArray(); | ||
|
||
$percentage = (float) ($array['metrics']['http_req_failed']['values']['fails'] * 100 / $array['metrics']['http_reqs']['values']['count']); | ||
|
||
return sprintf('%4.1f %%', $percentage); | ||
} | ||
|
||
/** | ||
* Gets the block color. | ||
*/ | ||
public function color(): string | ||
{ | ||
$array = $this->result->toArray(); | ||
|
||
return $array['metrics']['http_req_failed']['values']['fails'] === $array['metrics']['http_reqs']['values']['count'] | ||
? 'green' | ||
: 'red'; | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pest\Stressless\Contracts; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
interface Block | ||
{ | ||
/** | ||
* Gets the block value. | ||
*/ | ||
public function value(): string; | ||
|
||
/** | ||
* Gets the block color. | ||
*/ | ||
public function color(): string; | ||
} |
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 |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
|
||
namespace Pest\Stressless; | ||
|
||
use Pest\Stressless\ValueObjects\Result; | ||
|
||
/** | ||
* @internal | ||
* | ||
|
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
Oops, something went wrong.