cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Determine download speed

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 13 Jun 2010 19:25:59 +0200 (CEST)

On Sun, 13 Jun 2010, Patrick K. wrote:

> I want to determine the download speed. I tried to use get average speed
> while downloading. But the returned value was not useful at that state.

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

> So I tried to build something myself. I decided to call clock() to check how
> many cycles passed. Unfortunately the precision of this was too low.

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

> I remebered an entry in the mailing list to take look at progress.c to check
> out how the work was done there. Unfortunately I was not able to extract the
> logic. Maybe you have to know more source code of the library to get the
> idea.

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.

> Finally I tried gettimeofday but it didn't work either.

Then you did something really wrong. What does "didn't work" mean specificly?

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