본문 바로가기

* 리눅스

[명령어] curl 명령으로 웹사이트 로딩 속도를 테스트하는 방법

반응형

curl 명령으로 웹사이트 로딩 속도를 테스트하는 방법

curl 명령어 : https://scbyun.com/1005

curl 버전 정보

$ curl --version
curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.53.1 zlib/1.2.7 libidn/1.28 libssh2/1.8.0
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz unix-sockets

http code 출력

$ curl -s -o /dev/null -w '%{http_code}\n' https://scbyun.com
200

웹사이트 로딩 속도 테스트 #1

$ curl -s -w '\nTesting Website Response Time for: %{url_effective}\n\nLookup Time:\t\t%{time_namelookup}\nConnect Time:\t\t%{time_connect}\nPre-transfer Time:\t%{time_pretransfer}\nStart-transfer Time:\t%{time_starttransfer}\n\nTotal Time:\t\t%{time_total}\n' -o /dev/null https://scbyun.com
Testing Website Response Time for: https://scbyun.com/

Lookup Time:		0.004
Connect Time:		0.007
Pre-transfer Time:	0.208
Start-transfer Time:	0.526

Total Time:		0.529

웹사이트 로딩 속도 테스트 #2

curl-format.txt 파일 생성

$ vim curl-format.txt
    time_namelookup:  %{time_namelookup}\n
       time_connect:  %{time_connect}\n
    time_appconnect:  %{time_appconnect}\n
   time_pretransfer:  %{time_pretransfer}\n
      time_redirect:  %{time_redirect}\n
 time_starttransfer:  %{time_starttransfer}\n
                    ----------\n
         time_total:  %{time_total}\n
$ curl -w "@curl-format.txt" -o /dev/null -s https://scbyun.com
    time_namelookup:  0.004
       time_connect:  0.007
    time_appconnect:  0.210
   time_pretransfer:  0.210
      time_redirect:  0.000
 time_starttransfer:  0.488
                    ----------
         time_total:  0.488

부록 #1

$ for i in {1..3}; do curl -s -w "%{time_total}\n" -o /dev/null https://scbyun.com; done
0.689
0.566
0.737

사용 가능한 변수

content_type : The Content-Type of the requested document, if there was any.
filename_effective : The ultimate filename that curl writes out to. This is only meaningful if curl is told to write to a file with the --remote-name or --output option. It's most useful in combi‐nation with the --remote-header-name option. (Added in 7.25.1)
ftp_entry_path : The initial path curl ended up in when logging on to the remote FTP server. (Added in 7.15.4)
http_code : The numerical response code that was found in the last retrieved HTTP(S) or FTP(s) transfer. In 7.18.2 the alias response_code was added to show the same info.
http_connect : The numerical code that was found in the last response (from a proxy) to a curl CONNECT request. (Added in 7.12.4)
local_ip : The IP address of the local end of the most recently done connection - can be either IPv4 or IPv6 (Added in 7.29.0)
local_port : The local port number of the most recently done connection (Added in 7.29.0)
num_connects : Number of new connects made in the recent transfer. (Added in 7.12.3)
num_redirects : Number of redirects that were followed in the request. (Added in 7.12.3)
redirect_url : When an HTTP request was made without -L to follow redirects, this variable will show the actual URL a redirect would take you to. (Added in 7.18.2)
remote_ip : The remote IP address of the most recently done connection - can be either IPv4 or IPv6 (Added in 7.29.0)
remote_port : The remote port number of the most recently done connection (Added in 7.29.0)
size_download : The total amount of bytes that were downloaded.
size_header : The total amount of bytes of the downloaded headers.
size_request : The total amount of bytes that were sent in the HTTP request.
size_upload : The total amount of bytes that were uploaded.
speed_download : The average download speed that curl measured for the complete download. Bytes per second.
speed_upload : The average upload speed that curl measured for the complete upload. Bytes per second.
ssl_verify_result : The result of the SSL peer certificate verification that was requested. 0 means the verification was successful. (Added in 7.19.0)
time_appconnect : The time, in seconds, it took from the start until the SSL/SSH/etc connect/handshake to the remote host was completed. (Added in 7.19.0)
time_connect : The time, in seconds, it took from the start until the TCP connect to the remote host (or proxy) was completed.
speed_download : The average download speed that curl measured for the complete download. Bytes per second.
speed_upload : The average upload speed that curl measured for the complete upload. Bytes per second.
ssl_verify_result : The result of the SSL peer certificate verification that was requested. 0 means the verification was successful. (Added in 7.19.0)
time_appconnect : The time, in seconds, it took from the start until the SSL/SSH/etc connect/handshake to the remote host was completed. (Added in 7.19.0)
time_connect : The time, in seconds, it took from the start until the TCP connect to the remote host (or proxy) was completed.
time_namelookup : The time, in seconds, it took from the start until the name resolving was completed.
time_pretransfer : The time, in seconds, it took from the start until the file transfer was just about to begin. This includes all pre-transfer commands and negotiations that are specific to the particular protocol(s) involved.
time_redirect : The  time,  in  seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before the final transaction was started. time_redirect shows the complete execution time for multiple redirections. (Added in 7.12.3)
time_starttransfer : The time, in seconds, it took from the start until the first byte was just about to be transferred. This includes time_pretransfer and also the time the server needed to cal‐culate the result.
time_total : The total time, in seconds, that the full operation lasted. The time will be displayed with millisecond resolution.
url_effective : The URL that was fetched last. This is most meaningful if you've told curl to follow location: headers.


 

728x90
반응형