How to perform a latency test in iPhone

I would like to perform a latency test with respect to different urls in my iPhone app, an approach would be to make an async request for an url and measure the time duration based upon when the control reaches in connectionDidFinish delegate, is this the correct approach or some alternatives available in iPhone to measure latency time?

Answers


I am not sure how you define latency. Look at the wiki article for some clarification.

I'd profile for the response time to get a picture of the network lag, very interesting in mobile connections. I am using this approach in one of the apps I've developed:

- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse
{  
    ...
    self.reqStart = [NSDate date];
    self.url = [[request URL] absoluteString];
    NSLog(@"--> Requesting : %@", url);
    ...
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)aResponse
{
    NSLog(@"<-- Response time %fs : %@", [[NSDate date] timeIntervalSinceDate:reqStart], url);
    ...
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    NSLog(@"<== Request time %fs : %@", [[NSDate date] timeIntervalSinceDate:reqStart], url);
    ...
}

Throttling bandwidth for simulator testing could be very helpful.


Share your Mac's Airport to your iPhone (bridge it to Ethernet). Then use tcpdump on the Mac to capture the network traffic, using Wireshark to view the pcap, this will give you the best view of network latency.


Need Your Help

Bitnami Mean Stack

javascript angularjs node.js mean-stack bitnami

I have installed mean stack manager, but when I run command using node terminal console.log("Hello World") it works fine, but whenever I put Javascript sample file to any folder or anywhere in the ...

Linking Realm Data Instead of Copying

swift relationship realm

I have a lookup table (Book) in a Realm db that contains objects that can be referenced from other objects (Person in the below example). This lookup table (Book) has a primary key (id), and I get ...