서로 다른 사이트에 대한 두 컬 요청의 "time_total" 비교

서로 다른 사이트에 대한 두 컬 요청의 "time_total" 비교

time_total다음을 사용하여 컬 요청을 얻을 수 있다는 것을 알고 있습니다 .

curl https://www.google.com -s -o /dev/null -w "%{time_total}\n"

두 사이트의 결과를 쉽게 비교할 수 있는 방법이 있습니까 time_total?

예를 들어, 두 개의 명령이 있는 경우:

curl https://www.google.com -s -o /dev/null -w  "%{time_total}\n"
curl https://www.yahoo.com -s -o /dev/null -w  "%{time_total}\n"

Enter개별적으로 실행하는 대신 다음과 같은 내용을 표시하는 실행할 수 있는 명령(즉, 한 번만 누르면 됨) 을 갖고 싶습니다 .

0.186356 - https://www.google.com
0.535030 - https://www.yahoo.com

그게 가능합니까?

답변1

그냥 함수를 작성하세요:

speedtest() {
    for url
    do
      curl "$url" -s -o /dev/null -w  "%{time_total} - $url\n"
    done
}

그런 다음 원하는 수의 URL에서 실행할 수 있습니다.

$ speedtest https://www.google.com https://www.yahoo.com
0.055323 - https://www.google.com
0.544956 - https://www.yahoo.com

관련 정보