I am obtaining a json object containing an array of objects. I am willing to parse this json using the lib EVReflection
.
The operation takes a while, so I decided to monitorize the steps I'm taking, and realized the parsing of the json can take up to 20 seconds depending on the device.
Using iPhone SE / iOS 11.4 it takes 4 seconds aprox.
Using iPhone 5 / iOS 10.3 it takes 20 seconds aprox.
I am wondering if such variation is normal just depending on devices/OS.
Should I just use another lib or is there anything I can do to speed up the operation?
This is the code I'm using:
func getParkings(update: Bool) -> Observable<[ParkingEvo]> {
if let x = parkings, !update {
return Observable.just(x)
} else {
print("STEP 1: Calling API for parkings \(NSDate())")
return RxAlamofire.string(.get, PARKINGS_URL, parameters: getParameters(), headers: nil)
.map { self.parseParkings(json: $0) }
.do(onNext: { self.storeParkings($0) })
}
}
private func parseParkings(json: String) -> [ParkingEvo]{
print("STEP 2: Proceed to parse json \(NSDate())")
let parkingsDTO = ParkingsDTO(json: json)
print("STEP 3: ParkingsDTO created \(NSDate())")
return parkingsDTO.items
}
Between STEP2 and STEP3 there is the mentioned delay. Any idea on how to optimize this?
Thank you in advance.