generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
a32f364
commit 05a1098
Showing
53 changed files
with
1,728 additions
and
1,112 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
use Carbon\CarbonImmutable; | ||
use Illuminate\Support\Collection; | ||
use Orchestra\Testbench\Concerns\CreatesApplication; | ||
use PhpBench\Attributes\BeforeMethods; | ||
use PhpBench\Attributes\Iterations; | ||
use PhpBench\Attributes\Revs; | ||
use Spatie\LaravelData\LaravelDataServiceProvider; | ||
use Spatie\LaravelData\Optional; | ||
use Spatie\LaravelData\Support\DataConfig; | ||
use Spatie\LaravelData\Support\Types\Storage\AcceptedTypesStorage; | ||
use Spatie\LaravelData\Tests\Fakes\ComplicatedData; | ||
use Spatie\LaravelData\Tests\Fakes\SimpleData; | ||
|
||
class TestBench | ||
{ | ||
use CreatesApplication; | ||
|
||
public function __construct() | ||
{ | ||
$this->createApplication(); | ||
} | ||
|
||
protected function getPackageProviders($app) | ||
{ | ||
return [ | ||
LaravelDataServiceProvider::class, | ||
]; | ||
} | ||
|
||
#[Revs(5000), Iterations(5)] | ||
public function benchUseStored() | ||
{ | ||
for ($i = 0; $i < 100; $i++) { | ||
$this->runStored(); | ||
} | ||
} | ||
|
||
protected function runStored(): array | ||
{ | ||
return AcceptedTypesStorage::getAcceptedTypes(Collection::class); | ||
} | ||
|
||
#[Revs(5000), Iterations(5)] | ||
public function benchUseNative() | ||
{ | ||
for ($i = 0; $i < 100; $i++) { | ||
$this->runNative(); | ||
} | ||
} | ||
|
||
protected function runNative(): array | ||
{ | ||
return ! class_exists(Collection::class) ? [] : array_unique([ | ||
...array_values(class_parents(Collection::class)), | ||
...array_values(class_implements(Collection::class)), | ||
]); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.