단일 또는 다중 URL에 대한 최신 시간으로 측정합니다. 가장 빠르고 가장 느리고 중간 값 TTFB 값을 표시하고 선택적으로 모든 응답 헤더를 로그인 할 수 있습니다.

Usage: ttfb [options] url [url...]
-d debug
-l <log file> (infers -d) log response headers. Defaults to ./curl.log
-n <number> of times to test time to first byte
-o <option> pass options to curl (e.g. -o "-k" will make curl ignore invalid certificates)
-v verbose output. Show response breakdown (DNS lookup, TLS handshake etc)
Curl의 -L 옵션을 사용하여 리디렉션 체인을 암시 적으로 따릅니다.
모든 응답 헤더 (기본 로그 파일은 ./curl.log )를 로그인하여 -d 로 호출 할 수 있습니다.
-l /some/file 지정하여 기본 로그 파일을 대체하십시오.
URL을 호출 할 횟수를 지정하여 가장 빠르고 느리게 및 중앙 TTFB 값을 얻으십시오. 2 개의 테스트에는 -n2 사용하고 -n5 는 5 등을 사용하십시오.
연결 오버 헤드가 포함되지 않은 계산 %{time_starttransfer¹} - %{time_appconnect²} 사용하여 DevTool의 TTFB 그림을 더 잘 대략적으로 사용합니다.
¹ time_starttransfer
몇 초 만에, 첫 번째 바이트가 방금 전달 될 때까지 시작부터 시간이 걸렸습니다. 여기에는 time_pretransfer와 서버가 결과를 계산하는 데 필요한 시간이 포함됩니다.
² time_appconnect
시간은 몇 초 만에 SSL/SSH/etc 연결/핸드 셰이크가 원격 호스트에 완료 될 때까지 시작부터 시간이 걸렸습니다.
https://github.com/sandeepraju의 요점을 기반으로합니다
[email protected], @jaygooby에 의해 수정되었습니다
마스터 브랜치에서 스크립트를 다운로드하고 실행 파일로 만듭니다.
curl -LJO https://raw.githubusercontent.com/jaygooby/ttfb.sh/master/ttfb
chmod +x ./ttfb
Usage: ttfb [options] url [url...]
-d debug
-l <log file> (infers -d) log response headers. Defaults to ./curl.log
-n <number> of times to test time to first byte
-o <option> pass options to curl (e.g. -o "-k" will make curl ignore invalid certificates)
-v verbose output. Show response breakdown (DNS lookup, TLS handshake etc)
기본 사용 :
$ ttfb example.com
.227436
장황한 응답 분석을 통한 기본 사용 :
$ ttfb -v https://example.com
DNS lookup: 0.005152 TLS handshake: 0.000000 TTFB including connection: 0.200831 TTFB: .200831 Total time: 0.201132
여러 번 테스트 :
$ ttfb -n 5 example.com/example/url
.....
fastest .177263 slowest .214302 median .179957
여러 URL 테스트 :
$ ttfb bbc.co.uk news.bbc.co.uk
bbc.co.uk .049985
news.bbc.co.uk .054122
여러 번 여러 번 테스트하십시오.
$ ttfb -n 5 bbc.co.uk news.bbc.co.uk
.....
.....
bbc.co.uk fastest .030936 slowest .057755 median .034663
news.bbc.co.uk fastest .031413 slowest .182791 median .035001
다중 테스트가 지정 될 때 장악 응답 분해 :
$ ttfb -v -n 5 bbc.co.uk
DNS lookup: 0.005335 TLS handshake: 0.102314 TTFB including connection: 0.148328 TTFB: .046014 Total time: 0.646115
DNS lookup: 0.005322 TLS handshake: 0.102609 TTFB including connection: 0.150693 TTFB: .048084 Total time: 0.644611
DNS lookup: 0.004277 TLS handshake: 0.102066 TTFB including connection: 0.172199 TTFB: .070133 Total time: 1.196256
DNS lookup: 0.004444 TLS handshake: 0.107375 TTFB including connection: 0.160771 TTFB: .053396 Total time: 0.637290
DNS lookup: 0.005352 TLS handshake: 0.118882 TTFB including connection: 0.168772 TTFB: .049890 Total time: 0.653761
fastest .046014 slowest .070133 median .049890
여러 테스트를 위해 모든 응답 헤더를 여러 URL에 로그인합니다.
ttfb -d -n 2 bbc.co.uk https://www.bbc.co.uk/weather
..
..
bbc.co.uk fastest .027550 slowest .055215 median .041382
https://www.bbc.co.uk/weather fastest .101020 slowest .297923 median .199471
$ ls *.log
bbc_co_uk-curl.log https___www_bbc_co_uk_weather-curl.log
$ cat https___www_bbc_co_uk_weather-curl.log
HTTP/2 200
server: openresty
x-cache-action: MISS
vary: Accept-Encoding,X-BBC-Edge-Cache,X-BBC-Edge-Scheme,X-CDN
x-cache-age: 0
cache-control: private, stale-while-revalidate=10, max-age=0, must-revalidate
content-type: text/html;charset=utf-8
x-mrid: w1
date: Thu, 11 Apr 2019 17:08:07 GMT
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
x-lb-nocache: true
x-msig: 24e37f81323984e4e45b8048f9e3c94a
x-frame-options: SAMEORIGIN
content-length: 1077454
HTTP/2 200
server: openresty
x-cache-action: MISS
vary: Accept-Encoding,X-BBC-Edge-Cache,X-BBC-Edge-Scheme,X-CDN
x-cache-age: 0
cache-control: private, stale-while-revalidate=10, max-age=0, must-revalidate
content-type: text/html;charset=utf-8
x-mrid: w1
date: Thu, 11 Apr 2019 17:08:08 GMT
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
x-lb-nocache: true
x-msig: 24e37f81323984e4e45b8048f9e3c94a
x-frame-options: SAMEORIGIN
content-length: 1077454
CURL 변수가 전송의 다양한 단계와 어떻게 관련되는지에 대한 설명은 https://blog.cloudflare.com/a-question-of-timing/ 및 https://curl.haxx.se/docs/manpage.html을 참조하십시오.
DevTool의 TTFB의 더 나은 근사치를 얻으려면 연결 오버 헤드가없는 시간을 고려합니다. %{time_starttransfer} - %{time_appconnect}
더러운 eval 사용하여 TTFB 산술을 수행합니다. bc 및 column 명령에 따라 다릅니다.
PR을 제출하려면 기존의 모든 테스트가 통과하고 새로운 기능이 추가되면 테스트 스위트에 테스트를 추가하십시오.
테스트를 실행하려면 프로젝트 루트에서 make 호출하십시오. Bats-Core가 설치되어 있고 $PATH 에 설치해야합니다.
테스트 한두 개만 실행하려면 신경 쓰지 않는 테스트에서 # skip Line을 타협하므로 skip 읽으면 해당 테스트가 건너 뜁니다.
자세한 내용은 CONTRIBUTING.md 참조하십시오.
하나 이상의 요청 ( -n 2 등) 옵션이 설정되면 진행 상황 표시
-o 옵션 사용) 여러 URL이 제공 될 때 가장 빠른 TTFB로 출력을 정렬합니다.
색상 코드 TTFB: 응답 속도에 따라 표준 응답의 그림.