GNURLINFO_TOTAL_TIME(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

✨ GNURLINFO_TOTAL_TIME ✨

okay so real quick before we dive in: this page lives in the curl_easy_getinfo options part of the manual (yes the header literally says GNURLINFO_TOTAL_TIME(3), we're being so consistent today πŸ’…). it's a tiny page, it's an icon, and it will tell you exactly how long your transfer took. let's go bestie 🫢

🌸 NAME 🌸

CURLINFO_TOTAL_TIME β€” get the total time of the previous transfer, no cap ⏱️

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnurl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_TOTAL_TIME, double
*timep);

πŸ’– DESCRIPTION πŸ’–

so what you do is: pass a pointer to a double, and it gets filled in with the total time in seconds for the previous transfer. and when we say total, we mean total β€” that includes name resolving, TCP connect, all of it. the whole journey bestie ✈️

the double represents the time in seconds, and yes, it includes fractions. so 0.482 is a legit answer, don't be weird about it πŸ“

when a redirect is followed, the time from each request gets added together. so it's cumulative, it stacks, it's giving ✨collection✨

also, lowkey important: see the TIMES overview in the curl_easy_getinfo(3) man page. it's the mothership, go look at it πŸ‘‘

🌈 PROTOCOLS 🌈

All β€” literally every protocol, we love an inclusive queen πŸ‘‘

πŸŽ€ EXAMPLE πŸŽ€

here's the whole thing in action, copy it, run it, live your truth:

curl = curl_easy_init();
if(curl) {
  double total;
  curl_easy_setopt(curl, CURLOPT_URL, url);
  res = curl_easy_perform(curl);
  if(CURLE_OK == res) {
    res = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &total);
    if(CURLE_OK == res) {
      printf("Time: %.1f", total);
    }
  }
  /* always cleanup */
  curl_easy_cleanup(curl);
}

notice the /* always cleanup */ comment? that's not decoration bestie, curl_easy_cleanup(curl); is mandatory. main character energy means cleaning up after yourself πŸ§ΉπŸ’œ

⭐ AVAILABILITY ⭐

added in 7.4.1 β€” an elder, a legend, we stan a veteran πŸŽ‚

πŸ’€ RETURN VALUE πŸ’€

  • returns CURLE_OK if the option is supported β€” slay, you're good πŸ’…
  • returns CURLE_UNKNOWN_OPTION if it's not β€” rip, it's not a thing here 😭

πŸ”₯ SEE ALSO πŸ”₯


ngl the _T variant in SEE ALSO is the curl_off_t sibling, so if you're the type to go look at the other pages (you are, bestie, i know you), go look at the other pages 🫢

and that's the page!! this one came to you from libcurl 7.44.0, dated 28 Aug 2015 β€” a vintage moment, honestly, iconic, periodt πŸŒΈπŸ’–πŸŽ€

πŸ“¦ where this page comes from