Can someone help me with asihttprequest ?
I want to track the speed download of each file I download and not the average speed of all the files.
For the average spped of all downloads, there is [ASIHTTPRequest averageBandwidthUsedPerSecond]
but what can I use to track each downloads?
Thanks
Considering ASI is dead, I recently had to do this on an older project. If somebody else needs help:
-(void)request:(ASIHTTPRequest *)request didReceiveBytes:(long long)bytes
{
if (!lastBytesReceived)
lastBytesReceived = [NSDate date];
NSTimeInterval interval = [[NSDate date] timeIntervalSinceDate:lastBytesReceived];
float KB = (bytes / 1024);
float kbPerSec = KB * (1.0/interval); //KB * (1 second / interval (less than one second))
NSLog(@"%llu bytes received in %f seconds @ %0.01fKB/s",bytes,interval, kbPerSec);
lastBytesReceived = [NSDate date];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With