Skip to content

Commit 292d890

Browse files
authored
Add types for benchmarks (#2948)
1 parent e7ba865 commit 292d890

File tree

5 files changed

+14
-17
lines changed

5 files changed

+14
-17
lines changed

.github/workflows/performance.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
matrix:
1717
php-version:
1818
- "8.1"
19+
- "8.4"
1920

2021
services:
2122
mongodb:

benchmark/BaseBench.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Doctrine\ODM\MongoDB\Mapping\Driver\AttributeDriver;
1010
use MongoDB\Client;
1111
use MongoDB\Model\DatabaseInfo;
12-
use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods;
1312
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1413

1514
use function array_map;
@@ -19,14 +18,12 @@
1918

2019
use const PHP_VERSION_ID;
2120

22-
/** @BeforeMethods({"initDocumentManager", "clearDatabase"}) */
2321
abstract class BaseBench
2422
{
2523
public const DATABASE_NAME = 'doctrine_odm_performance';
2624
private const DEFAULT_MONGODB_SERVER = 'mongodb://localhost:27017';
2725

28-
/** @var DocumentManager */
29-
protected static $documentManager;
26+
protected static DocumentManager $documentManager;
3027

3128
protected function getDocumentManager(): DocumentManager
3229
{

benchmark/Document/HydrateDocumentBench.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,25 @@
1212
use PhpBench\Attributes\BeforeMethods;
1313
use PhpBench\Attributes\Warmup;
1414

15-
#[BeforeMethods(['init'])]
15+
#[BeforeMethods(['initDocumentManager', 'clearDatabase', 'init'])]
1616
final class HydrateDocumentBench extends BaseBench
1717
{
1818
/** @var array<string, mixed> */
19-
private static $data;
19+
private static array $data;
2020

2121
/** @var array<string, mixed> */
22-
private static $embedOneData;
22+
private static array $embedOneData;
2323

2424
/** @var array<string, mixed[]> */
25-
private static $embedManyData;
25+
private static array $embedManyData;
2626

2727
/** @var array<string, mixed[]> */
28-
private static $referenceOneData;
28+
private static array $referenceOneData;
2929

3030
/** @var array<string, mixed[]> */
31-
private static $referenceManyData;
31+
private static array $referenceManyData;
3232

33-
/** @var HydratorInterface */
34-
private static $hydrator;
33+
private static HydratorInterface $hydrator;
3534

3635
public function init(): void
3736
{

benchmark/Document/LoadDocumentBench.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717

1818
use function assert;
1919

20-
#[BeforeMethods(['init'])]
20+
#[BeforeMethods(['initDocumentManager', 'clearDatabase', 'init'])]
2121
final class LoadDocumentBench extends BaseBench
2222
{
23-
/** @var ObjectId */
24-
private static $userId;
23+
private static ObjectId $userId;
2524

2625
public function init(): void
2726
{
@@ -87,8 +86,7 @@ public function benchLoadReferenceMany(): void
8786
});
8887
}
8988

90-
/** @return User */
91-
private function loadDocument()
89+
private function loadDocument(): User
9290
{
9391
$document = $this->getDocumentManager()->find(User::class, self::$userId);
9492
assert($document instanceof User);

benchmark/Document/StoreDocumentBench.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
use Documents\Group;
1212
use Documents\Phonenumber;
1313
use Documents\User;
14+
use PhpBench\Attributes\BeforeMethods;
1415
use PhpBench\Attributes\Warmup;
1516

17+
#[BeforeMethods(['initDocumentManager', 'clearDatabase'])]
1618
final class StoreDocumentBench extends BaseBench
1719
{
1820
#[Warmup(2)]

0 commit comments

Comments
 (0)