Skip to content

Commit 1e22b58

Browse files
author
Kirill Nesmeyanov
committed
Improve benchmarks (again)
1 parent d7d7039 commit 1e22b58

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

tests/Bench/BenchInterface.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
interface BenchInterface
88
{
9-
public function benchTypeLangDocBlock(): void;
10-
public function benchTypeLangAttributes(): void;
11-
public function benchJms(): void;
12-
public function benchValinor(): void;
13-
public function benchSymfonyPhpStan(): void;
14-
public function benchSymfonyDocBlock(): void;
9+
public function benchTypeLangWithDocBlocks(): void;
10+
public function benchTypeLangWithAttributes(): void;
11+
public function benchJmsWithAttributes(): void;
12+
public function benchValinorWithPhpStan(): void;
13+
public function benchSymfonyWithPhpStan(): void;
14+
public function benchSymfonyWithDocBlock(): void;
1515
}

tests/Bench/DenormalizationBench.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
use JMS\Serializer\SerializerBuilder;
1212
use PhpBench\Attributes\BeforeMethods;
1313
use PhpBench\Attributes\Iterations;
14+
use PhpBench\Attributes\RetryThreshold;
1415
use PhpBench\Attributes\Revs;
1516
use PhpBench\Attributes\Warmup;
17+
use PHPUnit\Framework\Assert;
1618
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
1719
use Symfony\Component\PropertyInfo\Extractor\PhpStanExtractor;
1820
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
@@ -27,7 +29,7 @@
2729
use TypeLang\Mapper\Platform\StandardPlatform;
2830
use TypeLang\Mapper\Tests\Bench\Stub\ExampleRequestDTO;
2931

30-
#[Revs(100), Warmup(5), Iterations(10)]
32+
#[Revs(50), Warmup(5), Iterations(20), RetryThreshold(5)]
3133
#[BeforeMethods('prepare')]
3234
final class DenormalizationBench implements BenchInterface
3335
{
@@ -70,16 +72,16 @@ public function prepare(): void
7072
$this->typeLangDocBlock = new Mapper(
7173
platform: new StandardPlatform(
7274
driver: new DocBlockDriver(
73-
delegate: new ReflectionDriver()
74-
)
75+
delegate: new ReflectionDriver(),
76+
),
7577
),
7678
);
7779

7880
$this->typeLangAttributes = new Mapper(
7981
platform: new StandardPlatform(
8082
driver: new AttributeDriver(
81-
delegate: new ReflectionDriver()
82-
)
83+
delegate: new ReflectionDriver(),
84+
),
8385
),
8486
);
8587

@@ -101,32 +103,32 @@ public function prepare(): void
101103
]));
102104
}
103105

104-
public function benchJms(): void
106+
public function benchJmsWithAttributes(): void
105107
{
106108
$this->jms->fromArray(self::PAYLOAD, ExampleRequestDTO::class);
107109
}
108110

109-
public function benchValinor(): void
111+
public function benchValinorWithPhpStan(): void
110112
{
111113
$this->valinor->map(ExampleRequestDTO::class, Source::array(self::PAYLOAD));
112114
}
113115

114-
public function benchSymfonyPhpStan(): void
116+
public function benchSymfonyWithPhpStan(): void
115117
{
116118
$this->symfonyPhpStan->denormalize(self::PAYLOAD, ExampleRequestDTO::class);
117119
}
118120

119-
public function benchSymfonyDocBlock(): void
121+
public function benchSymfonyWithDocBlock(): void
120122
{
121123
$this->symfonyDocBlock->denormalize(self::PAYLOAD, ExampleRequestDTO::class);
122124
}
123125

124-
public function benchTypeLangDocBlock(): void
126+
public function benchTypeLangWithDocBlocks(): void
125127
{
126128
$this->typeLangDocBlock->denormalize(self::PAYLOAD, ExampleRequestDTO::class);
127129
}
128130

129-
public function benchTypeLangAttributes(): void
131+
public function benchTypeLangWithAttributes(): void
130132
{
131133
$this->typeLangDocBlock->denormalize(self::PAYLOAD, ExampleRequestDTO::class);
132134
}

tests/Bench/NormalizationBench.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44

55
namespace TypeLang\Mapper\Tests\Bench;
66

7-
use CuyZ\Valinor\Mapper\Source\Source;
8-
use CuyZ\Valinor\Mapper\TreeMapper;
97
use CuyZ\Valinor\MapperBuilder;
108
use CuyZ\Valinor\Normalizer\Format;
119
use CuyZ\Valinor\Normalizer\Normalizer;
1210
use JMS\Serializer\ArrayTransformerInterface;
1311
use JMS\Serializer\SerializerBuilder;
1412
use PhpBench\Attributes\BeforeMethods;
1513
use PhpBench\Attributes\Iterations;
14+
use PhpBench\Attributes\RetryThreshold;
1615
use PhpBench\Attributes\Revs;
1716
use PhpBench\Attributes\Warmup;
1817
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
@@ -29,7 +28,7 @@
2928
use TypeLang\Mapper\Platform\StandardPlatform;
3029
use TypeLang\Mapper\Tests\Bench\Stub\ExampleRequestDTO;
3130

32-
#[Revs(100), Warmup(5), Iterations(10)]
31+
#[Revs(50), Warmup(5), Iterations(20), RetryThreshold(5)]
3332
#[BeforeMethods('prepare')]
3433
final class NormalizationBench implements BenchInterface
3534
{
@@ -105,32 +104,32 @@ public function prepare(): void
105104
]));
106105
}
107106

108-
public function benchJms(): void
107+
public function benchJmsWithAttributes(): void
109108
{
110109
$this->jms->toArray($this->payload, type: ExampleRequestDTO::class);
111110
}
112111

113-
public function benchValinor(): void
112+
public function benchValinorWithPhpStan(): void
114113
{
115114
$this->valinor->normalize($this->payload);
116115
}
117116

118-
public function benchSymfonyPhpStan(): void
117+
public function benchSymfonyWithPhpStan(): void
119118
{
120119
$this->symfonyPhpStan->normalize($this->payload);
121120
}
122121

123-
public function benchSymfonyDocBlock(): void
122+
public function benchSymfonyWithDocBlock(): void
124123
{
125124
$this->symfonyDocBlock->normalize($this->payload);
126125
}
127126

128-
public function benchTypeLangDocBlock(): void
127+
public function benchTypeLangWithDocBlocks(): void
129128
{
130129
$this->typeLangDocBlock->normalize($this->payload);
131130
}
132131

133-
public function benchTypeLangAttributes(): void
132+
public function benchTypeLangWithAttributes(): void
134133
{
135134
$this->typeLangDocBlock->normalize($this->payload);
136135
}

0 commit comments

Comments
 (0)