-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ci: fix phpbench baseline on main * add example app to run benchmarks on for Lite/Symfony/Laravel * ci: remove cached files between benchmarks * refactor benchmarks * add PlaceOrderWithoutEcotoneBenchmark * clean ExampleApp * ci: remove opcache benchmark * skip without ecotone benchmark --------- Co-authored-by: jlabedo <jean@needelp.com>
- Loading branch information
Showing
73 changed files
with
2,080 additions
and
181 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 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,72 @@ | ||
<?php | ||
|
||
namespace Monorepo\Benchmark; | ||
|
||
use Monorepo\ExampleApp\Symfony\Kernel; | ||
use Psr\Container\ContainerInterface; | ||
|
||
abstract class FullAppBenchmarkCase | ||
{ | ||
public function bench_symfony_prod() | ||
{ | ||
\putenv('APP_ENV=prod'); | ||
$kernel = new Kernel('prod', false); | ||
$kernel->boot(); | ||
$container = $kernel->getContainer(); | ||
|
||
$this->execute($container); | ||
|
||
$kernel->shutdown(); | ||
} | ||
|
||
public function bench_symfony_dev() | ||
{ | ||
\putenv('APP_ENV=dev'); | ||
$kernel = new Kernel('dev', true); | ||
$kernel->boot(); | ||
$container = $kernel->getContainer(); | ||
|
||
$this->execute($container); | ||
|
||
$kernel->shutdown(); | ||
} | ||
|
||
public function bench_laravel_prod(): void | ||
{ | ||
\putenv('APP_ENV=production'); | ||
$app = $this->createLaravelApplication(); | ||
$this->execute($app); | ||
} | ||
|
||
public function bench_laravel_dev(): void | ||
{ | ||
\putenv('APP_ENV=development'); | ||
$app = $this->createLaravelApplication(); | ||
$this->execute($app); | ||
} | ||
|
||
public function bench_lite_prod() | ||
{ | ||
$bootstrap = require __DIR__ . "/../ExampleApp/Lite/app.php"; | ||
$messagingSystem = $bootstrap(true); | ||
$this->execute(new LiteContainerAccessor($messagingSystem)); | ||
} | ||
|
||
public function bench_lite_dev() | ||
{ | ||
$bootstrap = require __DIR__ . "/../ExampleApp/Lite/app.php"; | ||
$messagingSystem = $bootstrap(false); | ||
$this->execute(new LiteContainerAccessor($messagingSystem)); | ||
} | ||
|
||
private function createLaravelApplication() | ||
{ | ||
$app = require __DIR__ . '/../ExampleApp/Laravel/bootstrap/app.php'; | ||
|
||
$app->make(\Illuminate\Foundation\Http\Kernel::class)->bootstrap(); | ||
|
||
return $app; | ||
} | ||
|
||
protected abstract function execute(ContainerInterface $container): void; | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace Monorepo\Benchmark; | ||
|
||
use PhpBench\Attributes\Iterations; | ||
use PhpBench\Attributes\Revs; | ||
use PhpBench\Attributes\Warmup; | ||
use Psr\Container\ContainerInterface; | ||
|
||
#[Warmup(1), Revs(10), Iterations(5)] | ||
class KernelBootBenchmark extends FullAppBenchmarkCase | ||
{ | ||
protected function execute(ContainerInterface $container): void | ||
{ | ||
// do nothing | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace Monorepo\Benchmark; | ||
|
||
use Ecotone\Messaging\Config\MessagingSystem; | ||
use Psr\Container\ContainerInterface; | ||
|
||
class LiteContainerAccessor implements ContainerInterface | ||
{ | ||
public function __construct(private MessagingSystem $messagingSystem) | ||
{ | ||
} | ||
|
||
public function get(string $id) | ||
{ | ||
return $this->messagingSystem->getServiceFromContainer($id); | ||
} | ||
|
||
public function has(string $id): bool | ||
{ | ||
throw new \Exception("Not implemented"); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
|
||
namespace Monorepo\Benchmark; | ||
|
||
use Ecotone\Messaging\Config\ConfiguredMessagingSystem; | ||
use PhpBench\Attributes\Iterations; | ||
use PhpBench\Attributes\Revs; | ||
use PhpBench\Attributes\Warmup; | ||
use Psr\Container\ContainerInterface; | ||
|
||
#[Warmup(1), Revs(10), Iterations(5)] | ||
class MessagingBootBenchmark extends FullAppBenchmarkCase | ||
{ | ||
protected function execute(ContainerInterface $container): void | ||
{ | ||
$container->get(ConfiguredMessagingSystem::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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Monorepo\Benchmark; | ||
|
||
use Monorepo\ExampleApp\Common\Infrastructure\Configuration; | ||
use Monorepo\ExampleApp\Common\UI\OrderController; | ||
use PhpBench\Attributes\Iterations; | ||
use PhpBench\Attributes\Revs; | ||
use PhpBench\Attributes\Warmup; | ||
use Psr\Container\ContainerInterface; | ||
use Ramsey\Uuid\Uuid; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
#[Warmup(1), Revs(10), Iterations(5)] | ||
class PlaceOrderBenchmark extends FullAppBenchmarkCase | ||
{ | ||
protected function execute(ContainerInterface $container): void | ||
{ | ||
$orderController = $container->get(OrderController::class); | ||
$configuration = $container->get(Configuration::class); | ||
|
||
$orderController->placeOrder(new Request(content: json_encode([ | ||
'orderId' => Uuid::uuid4()->toString(), | ||
'address' => [ | ||
'street' => 'Washington', | ||
'houseNumber' => '15', | ||
'postCode' => '81-221', | ||
'country' => 'Netherlands' | ||
], | ||
'productId' => $configuration->productId(), | ||
]))); | ||
} | ||
} |
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,34 @@ | ||
<?php | ||
|
||
namespace Monorepo\Benchmark; | ||
|
||
use Monorepo\ExampleApp\Common\Infrastructure\Configuration; | ||
use Monorepo\ExampleApp\Common\UI\OrderControllerWithoutMessaging; | ||
use PhpBench\Attributes\Iterations; | ||
use PhpBench\Attributes\Revs; | ||
use PhpBench\Attributes\Skip; | ||
use PhpBench\Attributes\Warmup; | ||
use Psr\Container\ContainerInterface; | ||
use Ramsey\Uuid\Uuid; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
#[Skip, Warmup(1), Revs(10), Iterations(5)] | ||
class PlaceOrderWithoutEcotoneBenchmark extends FullAppBenchmarkCase | ||
{ | ||
protected function execute(ContainerInterface $container): void | ||
{ | ||
$orderController = $container->get(OrderControllerWithoutMessaging::class); | ||
$configuration = $container->get(Configuration::class); | ||
|
||
$orderController->placeOrder(new Request(content: json_encode([ | ||
'orderId' => Uuid::uuid4()->toString(), | ||
'address' => [ | ||
'street' => 'Washington', | ||
'houseNumber' => '15', | ||
'postCode' => '81-221', | ||
'country' => 'Netherlands' | ||
], | ||
'productId' => $configuration->productId(), | ||
]))); | ||
} | ||
} |
Oops, something went wrong.