I am downloading / uploading a few files with some progress tracking. All with the help of ASIHTTP
Currently I get progress of the task at some intervals, providing me the bytes downloaded. I wish to know how to get the download speed from this.
As per what I have read and thought it should be something like
while starting download, keep the start time and bytesOfDownloading
NSTimeInterval time1 = [[NSDate date] timeIntervalSince1970];
unsigned long long bytesOfDownloading1 = 0;
When you get the first process callback for progress You can get
NSTimeInterval time2 = [[NSDate date] timeIntervalSince1970];
unsigned long long bytesOfDownloading2 = bytesOfDownloading;
NSInteger timeDiff = (time2 - time1);
double transfer_rate = (bytesOfDownloading2 - bytesOfDownloading1) / timeDiff;
And keep new state
time1 = time2;
bytesOfDownload1 = bytesOfDownload2;
But my question is is there a way in which ASIHTTP or any other USURL related library directly gives me the transfer rate, without need for all such calculations
Thanks