![서로 다른 사이트에 대한 두 컬 요청의 "time_total" 비교](https://linux55.com/image/140878/%EC%84%9C%EB%A1%9C%20%EB%8B%A4%EB%A5%B8%20%EC%82%AC%EC%9D%B4%ED%8A%B8%EC%97%90%20%EB%8C%80%ED%95%9C%20%EB%91%90%20%EC%BB%AC%20%EC%9A%94%EC%B2%AD%EC%9D%98%20%22time_total%22%20%EB%B9%84%EA%B5%90.png)
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