Commit 07273df
committed
feature symfony#61497 [ObjectMapper] cache attributes in memory (soyuka)
This PR was submitted for the 7.3 branch but it was squashed and merged into the 7.4 branch instead.
Discussion
----------
[ObjectMapper] cache attributes in memory
| Q | A
| ------------- | ---
| Branch? | 7.3
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | na
| License | MIT
Profile:
<img width="1254" height="262" alt="20250821_22h15m27s_grim" src="https://github.com/user-attachments/assets/bf88422e-e01d-4768-aa1c-fdaa4dc87c38" />
<img width="1263" height="309" alt="20250821_22h15m12s_grim" src="https://github.com/user-attachments/assets/cd50f59d-7302-4cc0-8a25-2659922e0e89" />
<details>
<summary>phpbench</summary>
```php
<?php
namespace Symfony\Component\ObjectMapper\Benchmarks;
use PhpBench\Attributes as Bench;
use Symfony\Component\ObjectMapper\ObjectMapper;
use Symfony\Component\ObjectMapper\Tests\Fixtures\A;
use Symfony\Component\ObjectMapper\Tests\Fixtures\C;
use Symfony\Component\ObjectMapper\Tests\Fixtures\D;
#[Bench\BeforeMethods('setUp')]
class ObjectMapperBench
{
private ObjectMapper $objectMapper;
private A $sourceObject;
public function setUp(): void
{
$this->objectMapper = new ObjectMapper();
$d = new D(baz: 'foo', bat: 'bar');
$c = new C(foo: 'foo', bar: 'bar');
$this->sourceObject = new A();
$this->sourceObject->foo = 'test';
$this->sourceObject->transform = 'test';
$this->sourceObject->baz = 'me';
$this->sourceObject->notinb = 'test';
$this->sourceObject->relation = $c;
$this->sourceObject->relationNotMapped = $d;
}
#[Bench\Revs(100)]
#[Bench\Iterations(5)]
public function benchObjectMapper(): void
{
$this->objectMapper->map($this->sourceObject);
}
}
```
</details>
Commits
-------
3576a57 [ObjectMapper] cache attributes in memoryFile tree
1 file changed
+16
-6
lines changed- src/Symfony/Component/ObjectMapper/Metadata
1 file changed
+16
-6
lines changedLines changed: 16 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
32 | 42 | | |
33 | 43 | | |
34 | | - | |
| 44 | + | |
35 | 45 | | |
36 | 46 | | |
37 | 47 | | |
| |||
0 commit comments