From ae96b6ec9454e28d015b0483f8f1c0452c41898f Mon Sep 17 00:00:00 2001 From: MovsisianRG Date: Tue, 21 May 2024 22:42:06 +0300 Subject: [PATCH] code: edited for variant --- main.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 93168c0..996e576 100644 --- a/main.cpp +++ b/main.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); + 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;