How to improve performance with large amount of data objects? #1076
Unanswered
faustbrian
asked this question in
Q&A
Replies: 1 comment
-
Have you tried replacing your extends with Dto instead of Data? See https://spatie.be/docs/laravel-data/v4/as-a-data-transfer-object/creating-a-data-object |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I work with some APIs where representing the JSON responses as data objects can easily add up to a single data class that has 200+ data classes it has to create from the provided data.
I've tried to make use of https://spatie.be/docs/laravel-data/v4/advanced-usage/performance to improve performance but the difference is rather minuscule, for example the tests for all of those data classes combined went from 89s to 76s, which is decent but not world changing.
I've also tried to always skip validation or create the data classes via constructor instead of using
from
but neither really leads to meaningful improvements. I've done a draft implementation of an extremely slimmed down version that basically just supportsfrom
and somecasts
to compare the performance to theData
class and tests (without breaking) went from 89s to 2.3s.Is there any way that the overhead of this package can be reduced to the point of it being just a dumb data mapper other than the recommendations in https://spatie.be/docs/laravel-data/v4/advanced-usage/performance?
Beta Was this translation helpful? Give feedback.
All reactions