curl-library
Re: Please advise on how to improve libcurl HTTP GET performance
Date: Mon, 10 Oct 2011 13:40:32 -0700
your code looks pretty ok to me too from what i can see. You said it was
slower in release? That's weird...
I wonder if your byte array's append function might be slow?
You might try this profiler to see where all your time is going in case it's
the CPU that's the bottleneck:
http://www.codersnotes.com/sleepy
Nice profiler, very easy to use and you don't have to markup your code since
it takes statistical samples of where your code is in the execution stack
over time.
i wonder if something crazy might be going on, like your host throttles down
http requests that don't have a referer field in their header (or something
like that... something which browsers and the command line curl give, but
your program does not).
Maybe someone else has some other ideas :/
2011/10/10 Alex <Alexxxx89_at_ya.ru>
> 1) No way, I'm downloading to a memory buffer.
> 2) I didn't try telnet, but both Opera and console CURL tool download the
> very same page at ~300 KB/s, which is much closer to my actual net speed.
> Just a reminder: libcurl gives me 25-40 KB/s.
> Here's the code, you can see what page I'm testing on. CByteArray is just a
> wrapper for void* buffer, it's append uses realloc and memcpy.
> size_t onDownloadCallback( char* ptr, size_t size, size_t nmemb, void*
> receiver )
> {
> size_t actualSize = size * nmemb;
> CByteArray* dest = (CByteArray*) receiver;
> if (!dest)
> return 0;
> dest->append(ptr, actualSize);
> return actualSize;
> }
>
> void main ()
> {
> CURL *curl; CURLcode res;
>
> CHtmlPage page (CUrl(""));
> curl = curl_easy_init();
> time_t start,stop;
> if(curl) {
> curl_easy_setopt(curl, CURLOPT_WRITEDATA, &page.byteArray());
> curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, onDownloadCallback);
> curl_easy_setopt(curl, CURLOPT_URL, "
> http://www.math.utah.edu/~pa/math/largeprime.html");
> start = clock();
> res = curl_easy_perform(curl);
> stop = clock();
> curl_easy_cleanup(curl); }
>
> cout << "Download speed: " << page.byteArray().getSize() * 1000 /
> ((stop - start) * 1024) << " KB/s\n";
> }
> The code still looks perfectly OK to me, don't understand what's the
> bottleneck.
>
> Regards,
> Alex
> 10.10.2011, 20:51, "Alan Wolfe" <alan.wolfe_at_gmail.com>:
>
>
> #1 - Does your program block at all on disk i/o (are you reading or writing
> to the disk?) if so that could be bottlenecking your D/L.
> #2 - Are you sure the problem is on your end, not the server side?
>
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-10-10