1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLINFO_TOTAL_TIME_T
5Section: 3
6Source: libcurl
7See-also:
8  - CURLINFO_TOTAL_TIME (3)
9  - CURLOPT_TIMEOUT (3)
10  - curl_easy_getinfo (3)
11  - curl_easy_setopt (3)
12Protocol:
13  - All
14---
15# NAME
16
17CURLINFO_TOTAL_TIME_T - get total time of previous transfer in microseconds
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_TOTAL_TIME_T,
25                           curl_off_t *timep);
26~~~
27
28# DESCRIPTION
29
30Pass a pointer to a curl_off_t to receive the total time in microseconds
31for the previous transfer, including name resolving, TCP connect etc.
32The curl_off_t represents the time in microseconds.
33
34When a redirect is followed, the time from each request is added together.
35
36See also the TIMES overview in the curl_easy_getinfo(3) man page.
37
38# EXAMPLE
39
40~~~c
41int main(void)
42{
43  CURL *curl = curl_easy_init();
44  if(curl) {
45    CURLcode res;
46    curl_off_t total;
47    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
48    res = curl_easy_perform(curl);
49    if(CURLE_OK == res) {
50      res = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME_T, &total);
51      if(CURLE_OK == res) {
52        printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", total / 1000000,
53               (long)(total % 1000000));
54      }
55    }
56    /* always cleanup */
57    curl_easy_cleanup(curl);
58  }
59}
60~~~
61
62# AVAILABILITY
63
64Added in 7.61.0
65
66# RETURN VALUE
67
68Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
69