LibCurl zu langsam
-
Hi Leute
Ich arbeite aktuell mit LibCurl.
Dabei kommt es ein wenig auf Performance an.Der relevante Code:
int CConnectionSpooler::writer(char *data, size_t size, size_t nmemb, std::string *buffer) { int result = 0; if (buffer != NULL) { buffer->append(data, size * nmemb); result = size * nmemb; } return result; } bool CConnectionSpooler::GetHttpString( string &url, string *FeedbackString ) { if ( curl ) { char errorBuffer[ CURL_ERROR_SIZE ]; curl_easy_setopt( curl, CURLOPT_URL, url.c_str() ); curl_easy_setopt( curl, CURLOPT_HEADER, false ); curl_easy_setopt( curl, CURLOPT_FORBID_REUSE, true ); curl_easy_setopt( curl, CURLOPT_ERRORBUFFER, errorBuffer ); curl_easy_setopt( curl, CURLOPT_WRITEFUNCTION, writer ); curl_easy_setopt( curl, CURLOPT_WRITEDATA, FeedbackString ); curl_easy_setopt( curl, CURLOPT_USERAGENT, Username.c_str() ); curl_easy_setopt( curl, CURLOPT_TIMEOUT, 100 ); curl_easy_setopt( curl, CURLOPT_FOLLOWLOCATION, true ); curl_easy_setopt( curl, CURLOPT_MAXREDIRS, 20 ); curl_easy_setopt( curl, CURLOPT_FAILONERROR, true ); curl_easy_setopt( curl, CURLOPT_SSL_VERIFYHOST, false ); curl_easy_setopt( curl, CURLOPT_SSL_VERIFYPEER, false ); CURLcode res; res = curl_easy_perform( curl ); return ( res == CURLE_OK ); } return false; }
Ich lese derartige Seiten aus:
http://aktienkurs-orderbuch.finanznachrichten.de/tickerlist_DAI.aspxIch habe zum Test mal die Netzwerkauslastung meiner Linux-Maschine überprüft und festgestellt, dass die sehr viel kleiner ist als die Netzwerkauslastung beim FireFox ( gleiche URL ).
Beim FireFox sind es kurzzeitig mal 1,5 MBit/s und bei diesem CurlCode eher so maximal 5kBit/s...
Der ganze Vorgang dauert ca. 1Sek ( geschätzt ).Edit: der Rückgabe-String ist ca. 22.000 Zeichen lang. Ist also eigentlich keine große Datenmenge.
hat jemand eine Idee, woran das liegen kann?
Parameter bei LibCurl suboptimal?
gruß
Tobi
-
wget ist genauso langsam...
scheint wirklich nicht schneller zu gehen. Der FireFox hat vermutlich deswegen mehr Datenvolumen, weil er auch noch die Bilder auf der Seite runterlädt.