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
e27988a
commit 5566c75
Showing
22 changed files
with
746 additions
and
215 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 was deleted.
Oops, something went wrong.
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,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pest\Stressless\Result; | ||
|
||
use Pest\Stressless\ValueObjects\Result; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @property-read Duration $duration | ||
*/ | ||
final readonly class DnsLookup | ||
{ | ||
/** | ||
* Creates a new requests instance. | ||
*/ | ||
public function __construct(private Result $result) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Returns the details of the requests DNS Lookup duration. | ||
*/ | ||
public function duration(): Duration | ||
{ | ||
return new Duration($this->result->toArray()['metrics']['http_req_connecting']['values']); | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pest\Stressless\Result; | ||
|
||
use Pest\Stressless\ValueObjects\Result; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @property-read Duration $duration | ||
* @property-read Rate $data | ||
*/ | ||
final readonly class Download | ||
{ | ||
/** | ||
* Creates a new requests instance. | ||
*/ | ||
public function __construct(private Result $result) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Returns the details of the requests download data. | ||
*/ | ||
public function data(): Rate | ||
{ | ||
return new Rate($this->result->toArray()['metrics']['data_received']['values']); | ||
} | ||
|
||
/** | ||
* Returns the details of the requests download duration. | ||
*/ | ||
public function duration(): Duration | ||
{ | ||
return new Duration($this->result->toArray()['metrics']['http_req_receiving']['values']); | ||
} | ||
} |
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,84 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pest\Stressless\Result; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @property-read float $avg | ||
* @property-read float $min | ||
* @property-read float $med | ||
* @property-read float $max | ||
* @property-read float $p90 | ||
* @property-read float $p95 | ||
*/ | ||
final readonly class Duration | ||
{ | ||
/** | ||
* Creates a new duration instance. | ||
* | ||
* @param array{avg: float, min: float, med: float, max: float, "p(90)": float, "p(95)": float} $asArray | ||
*/ | ||
public function __construct(private array $asArray) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Returns the average duration. | ||
*/ | ||
public function avg(): float | ||
{ | ||
return $this->asArray['avg']; | ||
} | ||
|
||
/** | ||
* Returns the minimum duration. | ||
*/ | ||
public function min(): float | ||
{ | ||
return $this->asArray['min']; | ||
} | ||
|
||
/** | ||
* Returns the median duration. | ||
*/ | ||
public function med(): float | ||
{ | ||
return $this->asArray['med']; | ||
} | ||
|
||
/** | ||
* Returns the maximum duration. | ||
*/ | ||
public function max(): float | ||
{ | ||
return $this->asArray['max']; | ||
} | ||
|
||
/** | ||
* Returns the 90th percentile duration. | ||
*/ | ||
public function p90(): float | ||
{ | ||
return $this->asArray['p(90)']; | ||
} | ||
|
||
/** | ||
* Returns the 95th percentile duration. | ||
*/ | ||
public function p95(): float | ||
{ | ||
return $this->asArray['p(95)']; | ||
} | ||
|
||
/** | ||
* Proxies the properties to methods. | ||
*/ | ||
public function __get(string $name): mixed | ||
{ | ||
return $this->{$name}(); // @phpstan-ignore-line | ||
} | ||
} |
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,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pest\Stressless\Result; | ||
|
||
use Countable; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @property-read int $count | ||
* @property-read float $rate | ||
*/ | ||
final readonly class Rate implements Countable | ||
{ | ||
/** | ||
* Creates a new duration instance. | ||
* | ||
* @param array{rate: float, passes: int, fails: int}|array{rate: float, count: int} $asArray | ||
*/ | ||
public function __construct(private array $asArray) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Returns the rate. | ||
*/ | ||
public function rate(): float | ||
{ | ||
return $this->asArray['rate']; | ||
} | ||
|
||
/** | ||
* Returns the count. | ||
*/ | ||
public function count(): int | ||
{ | ||
return $this->asArray['passes'] ?? $this->asArray['count']; // @phpstan-ignore-line | ||
} | ||
|
||
/** | ||
* Proxies the properties to methods. | ||
*/ | ||
public function __get(string $name): mixed | ||
{ | ||
return $this->{$name}(); // @phpstan-ignore-line | ||
} | ||
} |
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,111 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pest\Stressless\Result; | ||
|
||
use Pest\Stressless\ValueObjects\Result; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @property-read Duration $duration | ||
* @property-read Download $download | ||
* @property-read Rate $failed | ||
* @property-read Server $server | ||
* @property-read Upload $upload | ||
* @property-read DnsLookup $dnsLookup | ||
* @property-read float $rate | ||
* @property-read int $count | ||
* @property-read TlsHandshake $tlsHandshake | ||
*/ | ||
final readonly class Requests | ||
{ | ||
/** | ||
* Creates a new requests instance. | ||
*/ | ||
public function __construct(private Result $result) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Returns the details of the requests duration. | ||
*/ | ||
public function duration(): Duration | ||
{ | ||
return new Duration($this->result->toArray()['metrics']['http_req_duration']['values']); | ||
} | ||
|
||
/** | ||
* Returns the details of the requests download. | ||
*/ | ||
public function download(): Download | ||
{ | ||
return new Download($this->result); | ||
} | ||
|
||
/** | ||
* Returns the details of the failed requests. | ||
*/ | ||
public function failed(): Rate | ||
{ | ||
return new Rate($this->result->toArray()['metrics']['http_req_failed']['values']); | ||
} | ||
|
||
/** | ||
* Returns the details of the requests server. | ||
*/ | ||
public function server(): Server | ||
{ | ||
return new Server($this->result); | ||
} | ||
|
||
/** | ||
* Returns the details of the requests upload. | ||
*/ | ||
public function upload(): Upload | ||
{ | ||
return new Upload($this->result); | ||
} | ||
|
||
/** | ||
* Returns the details of the requests DNS lookup. | ||
*/ | ||
public function dnsLookup(): DnsLookup | ||
{ | ||
return new DnsLookup($this->result); | ||
} | ||
|
||
/** | ||
* Returns the rate. | ||
*/ | ||
public function rate(): float | ||
{ | ||
return $this->result->toArray()['metrics']['http_reqs']['values']['rate']; | ||
} | ||
|
||
/** | ||
* Returns the count. | ||
*/ | ||
public function count(): int | ||
{ | ||
return $this->result->toArray()['metrics']['http_reqs']['values']['count']; | ||
} | ||
|
||
/** | ||
* Returns the details of the requests TLS handshake duration. | ||
*/ | ||
public function tlsHandshake(): TlsHandshake | ||
{ | ||
return new TlsHandshake($this->result); | ||
} | ||
|
||
/** | ||
* Proxies the properties to methods. | ||
*/ | ||
public function __get(string $name): mixed | ||
{ | ||
return $this->{$name}(); // @phpstan-ignore-line | ||
} | ||
} |
Oops, something went wrong.