파이문

curl 요청 및 응답 시간 자세히 보기 본문

TIL

curl 요청 및 응답 시간 자세히 보기

민Z 2020. 12. 10. 19:12

curl 로 특정 URL 을 요청할 일이 있어서 해보다가 request, response 시간을 자세히 측정할 수는 없는걸까? 하다가 찾아보았다.

 

1. curl-format.txt 란 파일을 생성하고 아래의 내용을 입력한다.

    time_namelookup:  %{time_namelookup}s\n
       time_connect:  %{time_connect}s\n
    time_appconnect:  %{time_appconnect}s\n
   time_pretransfer:  %{time_pretransfer}s\n
      time_redirect:  %{time_redirect}s\n
 time_starttransfer:  %{time_starttransfer}s\n
                    ----------\n
         time_total:  %{time_total}s\n

2. curl 을 사용할 때 아래 처럼 쓴다.

curl -w "@curl-format.txt" -o /dev/null -s "주소 입력"

3. 그러면 아래 처럼 cli 에서 보여진다.

    time_namelookup:  0.004151s
       time_connect:  0.005090s
    time_appconnect:  0.018481s
   time_pretransfer:  0.018504s
      time_redirect:  0.000000s
 time_starttransfer:  0.019474s
                    ----------
         time_total:  0.019502s

참고

stackoverflow.com/questions/18215389/how-do-i-measure-request-and-response-times-at-once-using-curl 

Comments