I'm trying my best to optimize the time it takes to load a webpage in my uiwebview. How can I track the number of milliseconds it takes to load it? This is more for me to see if my optimizations are working.
UPDATE: I've been using delegate methods, but the problem isn't knowing when it's finished loading, or when it began loading. I want to know how long it took from when it first began the request to when it finished loading the url (the actual time in milliseconds).
Set a property called NSDate *methodStart.
When you start loading webView:
methodStart = [NSDate date];
When finished do that:
NSDate *methodFinish = [NSDate date];
NSTimeInterval executionTime = [methodFinish timeIntervalSinceDate:methodStart];
NSLog(@"executionTime = %f", executionTime);
Take into account that a webView usually calls webViewDidFinishLoad:
a few times so you will get the NSLog a few times and the last one is the one you need.