curl을 이용한 time elapsed 확인할 수 있는 두가지 예제이다. 

구글 static map 호출시 얼마나 걸리는 지 코딩 전에 미리 테스트할 수 있었다.



1.  curl 의 -w 옵션에 다양한 매개변수를 주어 걸린 시간을 측정할 수 있다.

 $ curl -s -w "%{time_namelookup} %{time_connect} %{time_appconnect} %{time_pretransfer} %{time_redirect} %{time_starttransfer} %{time_total}\n" -o /dev/null 'https://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=15&size=300x200&maptype=roadmap


0.001 0.217 1.078 1.078 0.000 1.349 1.790



한 번이 아닌 여러 번 실행하여 적당히 실행할 수 있다.


$ for i in {1..3}; do curl -s -w "%{time_namelookup} %{time_connect} %{time_appconnect} %{time_pretransfer} %{time_redirect} %{time_starttransfer} %{time_total}\n" -o /dev/null 'https://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=15&size=300x200&maptype=roadmap'; done



0.001 0.217 1.078 1.078 0.000 1.349 1.790

0.001 0.171 0.781 0.781 0.000 1.090 1.263

0.001 0.181 0.784 0.784 0.000 1.101 1.281




2. curl 옵션 아닌 time 을 이용한다. 


time curl -I 'https://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=15&size=300x200&maptype=roadmap' 



여러 번 호출해서 통계를 내볼 수 있다.


$ for i in {1..3}; do time curl -I 'https://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=15&size=300x200&maptype=roadmap' ; done





HTTP/1.1 200 OK

Content-Type: image/png

Date: Sat, 22 Aug 2015 16:14:39 GMT

Expires: Sun, 23 Aug 2015 16:14:39 GMT

Cache-Control: public, max-age=86400

Vary: Accept-Language

Access-Control-Allow-Origin: *

Server: staticmap

Content-Length: 23448

X-XSS-Protection: 1; mode=block

X-Frame-Options: SAMEORIGIN

Alternate-Protocol: 443:quic,p=1

Alt-Svc: quic=":443"; p="1"; ma=604800



real 0m1.024s

user 0m0.037s

sys 0m0.010s

HTTP/1.1 200 OK

Content-Type: image/png

Date: Sat, 22 Aug 2015 16:14:40 GMT

Expires: Sun, 23 Aug 2015 16:14:40 GMT

Cache-Control: public, max-age=86400

Vary: Accept-Language

Access-Control-Allow-Origin: *

Server: staticmap

Content-Length: 23448

X-XSS-Protection: 1; mode=block

X-Frame-Options: SAMEORIGIN

Alternate-Protocol: 443:quic,p=1

Alt-Svc: quic=":443"; p="1"; ma=604800



real 0m1.533s

user 0m0.029s

sys 0m0.008s

HTTP/1.1 200 OK

Content-Type: image/png

Date: Sat, 22 Aug 2015 16:14:42 GMT

Expires: Sun, 23 Aug 2015 16:14:42 GMT

Cache-Control: public, max-age=86400

Vary: Accept-Language

Access-Control-Allow-Origin: *

Server: staticmap

Content-Length: 23448

X-XSS-Protection: 1; mode=block

X-Frame-Options: SAMEORIGIN

Alternate-Protocol: 443:quic,p=1

Alt-Svc: quic=":443"; p="1"; ma=604800



real 0m1.622s

user 0m0.030s

sys 0m0.008s





Posted by '김용환'
,