Open jayfray12 opened 6 years ago
Not sure if this helps or not but the call to
NSObject.setValue(_ value: Any?, forKey key: String)
in my project takes around 0.14ms where as in the EVReflection projects takes about 0.02ms
Have tried compiling with -O and -Ounchecked
I've set the Optimization Level to Optimize for Speed [-O] but that didn't seem to help
Do you have any strange libraries active in your project that could have 'swizzled' the setValue forKey function and does some extra work? It must come from somewhere that it almost takes 10 times as long.
Nothing to do with swizzling. If I run it in the Simulator it is fast (less than a second). If I run it on an actual iPad device it is slow. The device I choose in the Simulator is the same type of device as the actual iPad (Air). The only thing that is different from the Simulator to the iPad device is the iOS version. Simulator is running iOS 10 iPad is 11.4. I am downloading the 11.4 simulator version now to rule that out. Any reason that you can think of that would cause the difference from the device and the simulator?
Matching the iOS version didn't seem to help. When run on the iPad with the same iOS version it is much slower than the Simulator with the same device type and iOS version.
I can't think of any reason why this behavior would happen.
From what I've read it looks like the Simulator has more processing power than the actual devices which is why there is a discrepancy.
but then still 17KB of json should not take that long. I have done more parsing with bigger files that were faster than that.
Is it possible that a deep complex object structure to cause the slowdown? I'm having speed issues in my app as well. My guess is that I'm doing unnecessary processing by turning everything into objects.
I'm thinking of storing certain objects as json and then accessing them through lazy properties. Do you think that could be the cause @evermeer ?
Anyways as I was researching that found out that my problem was a problem with the CDN. When the CDN hits it's taking around 2 to 3 seconds to render 1.2mbs of Json in device. The structure is not that complex, it's just around 5 objects, with some nesting between them.
@mlomeli The complexity of the structure does not impact performance. The number of objects and properties does. 1.2MB of json is quite large and you should notice that rendering that takes time but it should probably be less than a second. Do you have a sample json file that I can test with?
I don't know what you mean with those lazy properties. It's possible to do custom processing for a property and then not handling it as an object but as a string. That could save you some time, but I don't think its worth the time of implementing it.
If timing becomes a problem, then you should try switching to codable. That's a lot faster. you would only miss some features. If you want almost as easy usage as EVReflection you could use https://github.com/evermeer/Stuff#codable
Nice. I tested it properly and the library is fast. At least timing is not a problem.
As a starting point is great, besides, my code ends up pretty similar in the Android version due to the Gson library also having reflection. The only reason I would switch is if I wanted to optimize CPU usage in order to save battery. But I'd need to test if it's worth it.
Anyways thanks for the continued support of this library.
I have about 17KB of data that I parse and it takes about 4s in my app. However I downloaded the EVReflection code, added my classes and ran the Performance Test and it runs in less than a second. Can you help point me in a direction as to what it is that is causing the slowdown in my app? Is there some sort of XCode setting or flag that I am missing? I can't seem to figure out why it is fast in the EVReflection project but not mine. Any help would be appreciated.