Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions bench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,19 @@ stream **writer** implementations:

| Writer / consumption | 1 000 | 20 000 | time (20k) |
|----------------------|------:|-------:|-----------:|
| **Symfony JSON streamer — `getIterator()` (streamed)** | **7.2 MB** | **7.2 MB** | **0.10 s** |
| Symfony JSON streamer — `__toString()` | 7.5 MB | 16 MB | 0.12 s |
| AutoMapper `mapCollection` + `json_encode` (eager) | 11 MB | 77 MB | 0.14 s |
| **AutoMapper JSON streamer — `STREAM=true` (streamed)** | 7.8 MB | **7.8 MB** | 0.15 s |
| AutoMapper JSON streamer — `__toString()` | 8.2 MB | 17 MB | 0.17 s |

Both streamed writers keep a **flat peak** whatever the collection size, and the
AutoMapper one is now within ~1.5× of Symfony's while running every element through the
full mapping pipeline. The eager `mapCollection` + `json_encode` path is comparable in
time but allocates the whole array-of-arrays (77 MB at 20k).
| **Symfony JSON streamer — `getIterator()` (streamed)** | **7.2 MB** | **7.2 MB** | **68 ms** |
| Symfony JSON streamer — `__toString()` | 7.5 MB | 16 MB | 76 ms |
| AutoMapper `mapCollection` + `json_encode` (eager, no attr checking) | 11 MB | 77 MB | 76 ms |
| **AutoMapper JSON streamer — `STREAM=true`, no attr checking** | 7.8 MB | **7.8 MB** | 95 ms |
| AutoMapper JSON streamer — `__toString()`, no attr checking | 8.2 MB | 17 MB | 104 ms |
| **AutoMapper JSON streamer — `STREAM=true` (streamed)** | 7.2 MB | **7.2 MB** | 170 ms |
| AutoMapper JSON streamer — `__toString()` | 7.5 MB | 16 MB | 180 ms |

Both streamed writers keep a **flat peak** whatever the collection size — an identical
one, in fact — while the AutoMapper writer runs every element through the full mapping
pipeline. That pipeline is what it costs: ~2.5× Symfony's time by default, ~1.4× with
`attributeChecking: false`. The eager `mapCollection` + `json_encode` path is as fast as
Symfony's streamer but allocates the whole array-of-arrays (77 MB at 20k).

### Collection — write one object with a big nested collection (`src/WriteWideObjectBench.php`)

Expand Down
1 change: 1 addition & 0 deletions bench/bin/verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'serialize' => Verifier::serializeResults(...),
'object-to-object' => Verifier::objectToObjectResults(...),
'collection' => Verifier::collectionResults(...),
'doctrine' => \Automapper\Bench\Doctrine\DoctrineFixture::results(...),
];

$exit = 0;
Expand Down
4 changes: 3 additions & 1 deletion bench/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"symfony/serializer": "^7.4 || ^8.0",
"symfony/type-info": "^7.4 || ^8.0",
"symfony/uid": "^7.4 || ^8.0",
"phpstan/phpdoc-parser": "^2.3"
"phpstan/phpdoc-parser": "^2.3",
"doctrine/orm": "^3.5",
"doctrine/dbal": "^4.2"
},
"autoload": {
"psr-4": {
Expand Down
Loading
Loading