@@ -19,32 +19,32 @@ The best PHP mapper you've ever seen =)
19
19
You can see some [ examples here] ( /example ) :
20
20
21
21
- [ 01.normalization] ( /example/01.normalization )
22
- - [ 01.object-normalization] ( /example/01.normalization/01.object-normalization.php )
23
- - [ 02.date-normalization] ( /example/01.normalization/02.date-normalization.php )
24
- - [ 03.date-format-normalization] ( /example/01.normalization/03.date-format-normalization.php )
25
- - [ 04.untyped-object-normalization] ( /example/01.normalization/04.untyped-object-normalization.php )
26
- - [ 05.typed-object-normalization] ( /example/01.normalization/05.typed-object-normalization.php )
27
- - [ 06.inherited-types-normalization] ( /example/01.normalization/06.inherited-types-normalization.php )
28
- - [ 07.collection-types-normalization] ( /example/01.normalization/07.collection-types-normalization.php )
29
- - [ 08.object-output-normalization] ( /example/01.normalization/08.object-output-normalization.php )
22
+ - [ 01.object-normalization] ( /example/01.normalization/01.object-normalization.php )
23
+ - [ 02.date-normalization] ( /example/01.normalization/02.date-normalization.php )
24
+ - [ 03.date-format-normalization] ( /example/01.normalization/03.date-format-normalization.php )
25
+ - [ 04.untyped-object-normalization] ( /example/01.normalization/04.untyped-object-normalization.php )
26
+ - [ 05.typed-object-normalization] ( /example/01.normalization/05.typed-object-normalization.php )
27
+ - [ 06.inherited-types-normalization] ( /example/01.normalization/06.inherited-types-normalization.php )
28
+ - [ 07.collection-types-normalization] ( /example/01.normalization/07.collection-types-normalization.php )
29
+ - [ 08.object-output-normalization] ( /example/01.normalization/08.object-output-normalization.php )
30
30
- [ 02.errors] ( /example/02.errors )
31
- - [ 01.custom-type-printer] ( /example/02.errors/01.custom-type-printer.php )
32
- - [ 02.extended-type-printer] ( /example/02.errors/02.extended-type-printer.php )
33
- - [ 03.custom-path-printer] ( /example/02.errors/03.custom-value-printer.php )
34
- - [ 04.custom-value-printer] ( /example/02.errors/04.custom-path-printer.php )
31
+ - [ 01.custom-type-printer] ( /example/02.errors/01.custom-type-printer.php )
32
+ - [ 02.extended-type-printer] ( /example/02.errors/02.extended-type-printer.php )
33
+ - [ 03.custom-path-printer] ( /example/02.errors/03.custom-value-printer.php )
34
+ - [ 04.custom-value-printer] ( /example/02.errors/04.custom-path-printer.php )
35
35
- [ 03.types] ( /example/03.types )
36
- - [ 01.type-platforms] ( /example/03.types/01.type-platforms.php )
37
- - [ 02.custom-type] ( /example/03.types/02.custom-type.php )
38
- - [ 03.custom-type-template-arguments] ( /example/03.types/03.custom-type-template-arguments.php )
39
- - [ 04.custom-platform] ( /example/03.types/04.custom-platform.php )
36
+ - [ 01.type-platforms] ( /example/03.types/01.type-platforms.php )
37
+ - [ 02.custom-type] ( /example/03.types/02.custom-type.php )
38
+ - [ 03.custom-type-template-arguments] ( /example/03.types/03.custom-type-template-arguments.php )
39
+ - [ 04.custom-platform] ( /example/03.types/04.custom-platform.php )
40
40
- [ 04.mapping] ( /example/04.mapping )
41
- - [ 01.reflection-mapping] ( /example/04.mapping/01.reflection-mapping.php )
42
- - [ 02.attribute-mapping] ( /example/04.mapping/02.attribute-mapping.php )
43
- - [ 03.driver-inheritance-mapping] ( /example/04.mapping/03.driver-inheritance-mapping.php )
44
- - [ 04.phpdoc-mapping] ( /example/04.mapping/04.phpdoc-mapping.php )
45
- - [ 05.phpdoc-custom-tags-mapping] ( /example/04.mapping/05.phpdoc-custom-tags-mapping.php )
46
- - [ 06.cache] ( /example/04.mapping/06.cache.php )
47
-
41
+ - [ 01.reflection-mapping] ( /example/04.mapping/01.reflection-mapping.php )
42
+ - [ 02.attribute-mapping] ( /example/04.mapping/02.attribute-mapping.php )
43
+ - [ 03.driver-inheritance-mapping] ( /example/04.mapping/03.driver-inheritance-mapping.php )
44
+ - [ 04.phpdoc-mapping] ( /example/04.mapping/04.phpdoc-mapping.php )
45
+ - [ 05.phpdoc-custom-tags-mapping] ( /example/04.mapping/05.phpdoc-custom-tags-mapping.php )
46
+ - [ 06.cache] ( /example/04.mapping/06.cache.php )
47
+
48
48
> Full documentation in progress...
49
49
50
50
## Installation
@@ -56,48 +56,6 @@ using the following command in a root of your project:
56
56
composer require type-lang/mapper
57
57
```
58
58
59
- ## Benchmarks
60
-
61
- Results [ here] ( https://github.com/php-type-language/mapper/actions/workflows/bench.yml )
62
- like [ this] ( https://github.com/php-type-language/mapper/actions/runs/11354044353/job/31580400799#step:7:34 ) .
63
-
64
- Sample: An object that contains a collection of objects, which contains
65
- another collection of objects.
66
-
67
- ``` typescript
68
- ExampleObject {
69
- name : string ,
70
- items : list < ExampleObject >
71
- }
72
- ```
73
-
74
- ### Denormalization
75
-
76
- Denormalization: Transformation from raw payload (array) to concrete object.
77
-
78
- | subject | revs | its | mem_peak | mode | rstdev |
79
- | -----------------------------| ------| -----| ----------| -----------| --------|
80
- | benchJmsWithAttributes | 50 | 20 | 4.466mb | 32.151μs | ±1.70% |
81
- | benchTypeLangWithDocBlocks | 50 | 20 | 3.870mb | 34.175μs | ±1.61% |
82
- | benchTypeLangWithAttributes | 50 | 20 | 3.870mb | 34.379μs | ±1.77% |
83
- | benchValinorWithPhpStan | 50 | 20 | 3.870mb | 119.750μs | ±1.21% |
84
- | benchSymfonyWithDocBlock | 50 | 20 | 3.870mb | 123.889μs | ±1.35% |
85
- | benchSymfonyWithPhpStan | 50 | 20 | 3.870mb | 126.807μs | ±1.94% |
86
-
87
- ### Normalization
88
-
89
- Normalization: Transformation from object to raw payload (array).
90
-
91
- | subject | revs | its | mem_peak | mode | rstdev |
92
- | -----------------------------| ------| -----| ----------| ----------| --------|
93
- | benchTypeLangWithDocBlocks | 50 | 20 | 3.870mb | 36.473μs | ±1.69% |
94
- | benchTypeLangWithAttributes | 50 | 20 | 3.870mb | 36.735μs | ±1.68% |
95
- | benchSymfonyWithPhpStan | 50 | 20 | 3.870mb | 37.050μs | ±1.20% |
96
- | benchSymfonyWithDocBlock | 50 | 20 | 3.870mb | 37.125μs | ±1.50% |
97
- | benchValinorWithPhpStan | 50 | 20 | 3.870mb | 38.229μs | ±1.38% |
98
- | benchJmsWithAttributes | 50 | 20 | 3.870mb | 44.614μs | ±1.92% |
99
-
100
-
101
59
## Quick Start
102
60
103
61
``` php
@@ -146,3 +104,71 @@ $result = $mapper->denormalize([
146
104
// InvalidFieldTypeValueException: Passed value of field "names" must be of type
147
105
// list<non-empty-string >, but array(3)["first", "second", ""] given at $.names[2]
148
106
```
107
+
108
+ ## Benchmarks
109
+
110
+ Results [ here] ( https://github.com/php-type-language/mapper/actions/workflows/bench.yml )
111
+ like [ this] ( https://github.com/php-type-language/mapper/actions/runs/11924690471/job/33235475673#step:6:10 ) .
112
+
113
+ Sample: An object that contains a collection of objects, which contains
114
+ another collection of objects.
115
+
116
+ ``` typescript
117
+ ExampleObject
118
+ {
119
+ name : string ,
120
+ items
121
+ :
122
+ list < ExampleObject >
123
+ }
124
+ ```
125
+
126
+ The results are sorted by mode time.
127
+
128
+ ### Denormalization
129
+
130
+ Denormalization: Transformation from raw payload (array) to concrete object.
131
+
132
+ | benchmark | memory | min | max | mode | rstdev |
133
+ | -------------------------| ---------| -----------| -----------| -----------| --------|
134
+ | TypeLangAttributesBench | 1.444mb | 141.800μs | 156.050μs | 145.760μs | ±2.13% |
135
+ | JMSAttributesBench | 1.429mb | 144.400μs | 157.100μs | 146.736μs | ±2.12% |
136
+ | TypeLangDocBlockBench | 1.642mb | 144.800μs | 153.850μs | 148.059μs | ±1.29% |
137
+ | ValinorBench | 1.344mb | 217.550μs | 229.150μs | 220.319μs | ±1.41% |
138
+ | SymfonyDocBlockBench | 2.163mb | 495.350μs | 507.950μs | 499.492μs | ±0.72% |
139
+ | SymfonyPHPStanBench | 1.426mb | 506.650μs | 544.500μs | 510.798μs | ±1.53% |
140
+
141
+ ### Denormalization + Cache
142
+
143
+ | benchmark | memory | min | max | mode | rstdev |
144
+ | -------------------------| ---------| -----------| -----------| -----------| --------|
145
+ | TypeLangDocBlockBench | 1.544mb | 113.250μs | 125.350μs | 115.831μs | ±2.64% |
146
+ | JMSAttributesBench | 1.429mb | 125.850μs | 148.750μs | 128.718μs | ±3.68% |
147
+ | TypeLangAttributesBench | 1.436mb | 170.100μs | 182.200μs | 173.155μs | ±1.70% |
148
+ | ValinorBench | 1.257mb | 341.000μs | 374.450μs | 346.891μs | ±1.94% |
149
+ | SymfonyPHPStanBench | 1.370mb | 583.600μs | 609.050μs | 590.473μs | ±0.88% |
150
+ | SymfonyDocBlockBench | 2.163mb | 644.350μs | 686.550μs | 651.617μs | ±1.32% |
151
+
152
+ ### Normalization
153
+
154
+ Normalization: Transformation from object to raw payload (array).
155
+
156
+ | benchmark | memory | min | max | mode | rstdev |
157
+ | -------------------------| ---------| -----------| -----------| -----------| --------|
158
+ | JMSAttributesBench | 1.476mb | 93.550μs | 125.100μs | 112.011μs | ±9.21% |
159
+ | TypeLangDocBlockBench | 1.643mb | 110.650μs | 133.000μs | 112.881μs | ±4.25% |
160
+ | SymfonyPHPStanBench | 1.370mb | 112.850μs | 121.850μs | 115.140μs | ±1.89% |
161
+ | TypeLangAttributesBench | 1.444mb | 117.300μs | 127.250μs | 120.649μs | ±2.43% |
162
+ | ValinorBench | 1.251mb | 127.300μs | 135.350μs | 129.379μs | ±1.72% |
163
+ | SymfonyDocBlockBench | 2.163mb | 153.000μs | 161.800μs | 155.170μs | ±1.39% |
164
+
165
+ ### Normalization + Cache
166
+
167
+ | benchmark | memory | min | max | mode | rstdev |
168
+ | -------------------------| ---------| -----------| -----------| -----------| --------|
169
+ | TypeLangAttributesBench | 1.447mb | 65.850μs | 94.650μs | 91.945μs | ±6.51% |
170
+ | TypeLangDocBlockBench | 1.544mb | 91.950μs | 97.250μs | 93.070μs | ±1.49% |
171
+ | JMSAttributesBench | 1.429mb | 88.150μs | 105.600μs | 100.956μs | ±3.31% |
172
+ | SymfonyPHPStanBench | 1.370mb | 136.050μs | 147.900μs | 138.879μs | ±1.96% |
173
+ | ValinorBench | 1.256mb | 114.450μs | 161.600μs | 152.558μs | ±5.88% |
174
+ | SymfonyDocBlockBench | 2.163mb | 164.300μs | 221.300μs | 212.265μs | ±5.18% |
0 commit comments