-
Notifications
You must be signed in to change notification settings - Fork 185
Performance optimization #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Now that you don't seem to do any new commits to this patch: |
src/JsonProperty.php
Outdated
@@ -0,0 +1,30 @@ | |||
<?php | |||
|
|||
class JsonProperty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would need a proper name. The project consists of two classes, one of it an exception, as of now, and I believe it isn't ideal if you add random new class names into the root namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good idea to use arrays or other names.
The |
I was trying to verify the performance claims, and noticed something odd: Running your branch is indeed faster (caveat: you didn't provide the full code to simply copy&paste into a file, then run it, so I had to patch something that now represents MY performance test), however you claimed that you cannot include the classMap feature because that is the slow part. I compared against the 5.0.0 master and did two different things:
In both cases, the execution was slighly SLOWER compared to the unaltered master branch. Not by a far margin, fluctuation at around 1%, so easily explained by multitasking effects on my machine. Anyways, I believe the classMap feature isn't to blame here, at least not for your suggested performance test case, as we'd be talking about one additional method call ( My measurements (long execution times likely caused by improper configuration of Xdebug):
As a general observation: The data structure you are enhancing is already representing analysis results in itself. So the return value of While I do admit I don't really like the Long story short: I am in favor of a proper cache info structure that hosts everything the JsonMapper knows about the target, including And addtionally, keep the classMap feature. It might turn into an additional attribute, even though it is highly dynamic in nature as results may depend on both original type and value to be mapped, based on a closure. |
Optimizing the map method can bring about decent performance
It takes 6.86 seconds before modification
It takes 4.84 seconds after modification
However, the
classMap
function will no longer be supported