Artifactspublic-v0

curl

master
ply4 git calls447 ms289 KiB1 cachedprotocol v2
240 lines7.0 KiBRaw
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24/* <DESC>
25 * Show transfer timing info after download completes.
26 * </DESC>
27 */
28/* Example source code to show how the callback function can be used to
29 * download data into a chunk of memory instead of storing it in a file.
30 * After successful download we use curl_easy_getinfo() calls to get the
31 * amount of downloaded bytes, the time used for the whole download, and
32 * the average download speed.
33 * On Linux you can create the download test files with:
34 * dd if=/dev/urandom of=file_1M.bin bs=1M count=1
35 *
36 */
37#ifdef _MSC_VER
38#ifndef _CRT_SECURE_NO_WARNINGS
39#define _CRT_SECURE_NO_WARNINGS /* for ctime() */
40#endif
41#endif
43#include <stdio.h>
44#include <stdlib.h>
45#include <time.h>
47#include <curl/curl.h>
49#define URL_BASE "http://speedtest.your.domain/"
50#define URL_1M URL_BASE "file_1M.bin"
51#define URL_2M URL_BASE "file_2M.bin"
52#define URL_5M URL_BASE "file_5M.bin"
53#define URL_10M URL_BASE "file_10M.bin"
54#define URL_20M URL_BASE "file_20M.bin"
55#define URL_50M URL_BASE "file_50M.bin"
56#define URL_100M URL_BASE "file_100M.bin"
58#define CHKSPEED_VERSION "1.0"
60static size_t write_cb(char *ptr, size_t size, size_t nmemb, void *data)
62 /* we are not interested in the downloaded bytes itself,
63 so we only return the size we would have saved ... */
64 (void)ptr;
65 (void)data;
66 return size * nmemb;
69int main(int argc, const char *argv[])
71 CURL *curl;
72 CURLcode result;
73 int prtall = 0, prtsep = 0, prttime = 0;
74 const char *url = URL_1M;
75 const char *appname = argv[0];
77 if(argc > 1) {
78 /* parse input parameters */
79 for(argc--, argv++; *argv; argc--, argv++) {
80 if(argv[0][0] == '-') {
81 switch(argv[0][1]) {
82 case 'h':
83 case 'H':
84 fprintf(stderr,
85 "\rUsage: %s [-m=1|2|5|10|20|50|100] [-t] [-x] [url]\n",
86 appname);
87 return 1;
88 case 'v':
89 case 'V':
90 fprintf(stderr, "\r%s %s - %s\n",
91 appname, CHKSPEED_VERSION, curl_version());
92 return 1;
93 case 'a':
94 case 'A':
95 prtall = 1;
96 break;
97 case 'x':
98 case 'X':
99 prtsep = 1;
100 break;
101 case 't':
102 case 'T':
103 prttime = 1;
104 break;
105 case 'm':
106 case 'M':
107 if(argv[0][2] == '=') {
108 int m = atoi(*argv + 3);
109 switch(m) {
110 case 1:
111 url = URL_1M;
112 break;
113 case 2:
114 url = URL_2M;
115 break;
116 case 5:
117 url = URL_5M;
118 break;
119 case 10:
120 url = URL_10M;
121 break;
122 case 20:
123 url = URL_20M;
124 break;
125 case 50:
126 url = URL_50M;
127 break;
128 case 100:
129 url = URL_100M;
130 break;
131 default:
132 fprintf(stderr, "\r%s: invalid parameter %s\n",
133 appname, *argv + 3);
134 return 1;
135 }
136 break;
137 }
138 fprintf(stderr, "\r%s: invalid or unknown option %s\n",
139 appname, *argv);
140 return 1;
141 default:
142 fprintf(stderr, "\r%s: invalid or unknown option %s\n",
143 appname, *argv);
144 return 1;
145 }
146 }
147 else {
148 url = *argv;
149 }
150 }
151 }
153 /* print separator line */
154 if(prtsep) {
155 printf("-------------------------------------------------\n");
156 }
157 /* print localtime */
158 if(prttime) {
159 time_t t = time(NULL);
160 printf("Localtime: %s", ctime(&t));
161 }
163 /* init libcurl */
164 result = curl_global_init(CURL_GLOBAL_ALL);
165 if(result != CURLE_OK)
166 return (int)result;
168 /* init the curl session */
169 curl = curl_easy_init();
170 if(curl) {
172 /* specify URL to get */
173 curl_easy_setopt(curl, CURLOPT_URL, url);
175 /* send all data to this function */
176 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
178 /* some servers do not like requests that are made without a user-agent
179 field, so we provide one */
180 curl_easy_setopt(curl, CURLOPT_USERAGENT,
181 "libcurl-speedchecker/" CHKSPEED_VERSION);
183 /* get it! */
184 result = curl_easy_perform(curl);
186 if(result == CURLE_OK) {
187 curl_off_t val;
189 /* check for bytes downloaded */
190 result = curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD_T, &val);
191 if((result == CURLE_OK) && (val > 0))
192 printf("Data downloaded: %" CURL_FORMAT_CURL_OFF_T " bytes.\n", val);
194 /* check for total download time */
195 result = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME_T, &val);
196 if((result == CURLE_OK) && (val > 0))
197 printf("Total download time: %" CURL_FORMAT_CURL_OFF_T
198 ".%06" CURL_FORMAT_CURL_OFF_T " sec.\n",
199 val / 1000000,
200 val % 1000000);
202 /* check for average download speed */
203 result = curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD_T, &val);
204 if((result == CURLE_OK) && (val > 0))
205 printf("Average download speed: "
206 "%" CURL_FORMAT_CURL_OFF_T " kbyte/sec.\n",
207 val / 1024);
209 if(prtall) {
210 /* check for name resolution time */
211 result = curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME_T, &val);
212 if((result == CURLE_OK) && (val > 0))
213 printf("Name lookup time: %" CURL_FORMAT_CURL_OFF_T
214 ".%06" CURL_FORMAT_CURL_OFF_T " sec.\n",
215 val / 1000000,
216 val % 1000000);
218 /* check for connect time */
219 result = curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME_T, &val);
220 if((result == CURLE_OK) && (val > 0))
221 printf("Connect time: %" CURL_FORMAT_CURL_OFF_T
222 ".%06" CURL_FORMAT_CURL_OFF_T " sec.\n",
223 val / 1000000,
224 val % 1000000);
225 }
226 }
227 else {
228 fprintf(stderr, "Error while fetching '%s' : %s\n",
229 url, curl_easy_strerror(result));
230 }
232 /* cleanup curl stuff */
233 curl_easy_cleanup(curl);
234 }
236 /* we are done with libcurl, so clean it up */
237 curl_global_cleanup();
239 return 0;
Diagnostics4 git calls · 447 ms
CallStatusSizeTime0447 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=149
git.response.cache=UPDATING
git.response.duration_ms=3
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=441
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2002.4 KiB441 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2478
git.response.cache=MISS
git.response.duration_ms=441
git.fetch.wants=7010acc4aeca65b3c347f4cc38cf5103ad08a9a6
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=2478
git.pkt.payload.max=2457
git.sideband.band1.bytes=2456
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e2124d6f33c6f8
Request
981ec842…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format