cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Determine download speed

From: Patrick K. <cooldie_1_at_hotmail.com>
Date: Sun, 13 Jun 2010 21:08:44 +0200

> I assume you're talking about the curl_easy_getinfo() data here?

Yes that is correct.

> Sorry, but for average download speed how high precision are you really aiming
> for? Surely even just full seconds should get you far?

I don't need a very high precision but I need a value that looks alright.
Imagine I'm downloading a file at 1600kb/s which in this case is the maximum for the used connection.
Now I'm starting another download. What happens is that the speed is divided to both downloads.

On my try with the average speed this scenario didn't work very good.
I got a total speed that was much about the possibility for the used connection.
But I have to look at it again to be sure if it is not me who made a mistake.

I should mention that I asked for the average speed before the download was finished.
(Is this legal or doesn't it work for a not finished download?)

> No, the progress and download speed logic is all gathered in that single
> source file so if you can't figure it out from there, getting more source code
> won't help.
 
> But libcurl does nothing magical in that aspect (either). It just counts
> number of bytes transfered divided by the time spent.

I'll take a look at it back again.

But maybe I'm just doing something else wrong. Lets assume this is how my callback looks like (I'm using C++ Classes so the static is needed):
static int callback(char *data, unsigned int size, unsigned int nmemb, void *ptr);

So the total size of data that had been received is (size * nmemb).

So inside the function I'm checking how much time passed.
The time that had been passed I convert into seconds and divide it by (size * nmemb) to get the download speed.

Is it right that way? The size of received that had been constant while testing. Something around ~16000.

Thanks :-)

Patrick K.
                                               
_________________________________________________________________
http://redirect.gimas.net/?n=M1006xHm2
Entdecken Sie die tollen neuen Funktionen von Hotmail!

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-06-13