From 891f04064cadf1bf7c442313b1b89712607d89a1 Mon Sep 17 00:00:00 2001 From: "Dima (AntonovDA)" <AntonovDAn@mpei.ru> Date: Mon, 20 May 2024 17:20:21 +0300 Subject: [PATCH] code: for my var --- l03.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/l03.cpp b/l03.cpp index cdeadef..1d1f3d4 100644 --- a/l03.cpp +++ b/l03.cpp @@ -72,19 +72,26 @@ Input download(const string &address) if (curl) { CURLcode res; + double total; curl_easy_setopt(curl, CURLOPT_URL, address.c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer); + res = curl_easy_perform(curl); - - // res = curl_easy_perform(curl); if (res != CURLE_OK) { + fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); exit(1); } + + if (CURLE_OK == res) + { + res = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &total); + cerr << "Time spending for downloading file: " << total << endl; + } curl_easy_cleanup(curl); } } @@ -92,7 +99,6 @@ Input download(const string &address) return input_data(buffer, false); } - int main(int argc, char *argv[]) { Input input;