All Projects → jaygooby → Ttfb.sh

jaygooby / Ttfb.sh

Licence: mit
Measures time-to-first-byte in seconds, for single or multiple URLs. Can calculate fastest, slowest & median TTFB values, and optionally log all response headers. Uses curl and the calculation `%{time_starttransfer} - %{time_appconnect}` which doesn't include any connection overhead, to better approximate devtool’s TTFB figure.

Programming Languages

shell
77523 projects

Labels

Projects that are alternatives of or similar to Ttfb.sh

Steamcmd Autoupdate Any Gameserver
Windows SteamCMD to autoupdate and install any game server steam cmd settings configurable lots of useful features. This batch script will keep your game servers automaticly updated updating intervals announce the server is shutting down for updates etc all configurable.
Stars: ✭ 77 (-37.4%)
Mutual labels:  curl
Wsend Gpg
Encrypted end to end file transfer
Stars: ✭ 97 (-21.14%)
Mutual labels:  curl
H2c
headers 2 curl. Provided a set of HTTP request headers, output the curl command line for generating that set. Try the converter online at
Stars: ✭ 113 (-8.13%)
Mutual labels:  curl
Androidhttp
Android Http网络开发神兵利器
Stars: ✭ 88 (-28.46%)
Mutual labels:  curl
Curl2httpie
covert command arguments between cURL and HTTPie
Stars: ✭ 92 (-25.2%)
Mutual labels:  curl
Gql
Very simple CLI for many GraphQL schemas in the cloud. Provides autocompletion for GraphQL queries
Stars: ✭ 101 (-17.89%)
Mutual labels:  curl
Cognitocurl
🦉🤖Easily sign curl calls to API Gateway with Cognito authorization token.
Stars: ✭ 76 (-38.21%)
Mutual labels:  curl
Twurl
OAuth-enabled curl for the Twitter API
Stars: ✭ 1,648 (+1239.84%)
Mutual labels:  curl
Getnews.tech
A web server that fetches data from the News API and formats it for display in the terminal.
Stars: ✭ 94 (-23.58%)
Mutual labels:  curl
Wuzz
Interactive cli tool for HTTP inspection
Stars: ✭ 9,845 (+7904.07%)
Mutual labels:  curl
Curl Tap Sh
tap curl in your editor before it gets to sh it
Stars: ✭ 89 (-27.64%)
Mutual labels:  curl
Katipo
HTTP2 client for Erlang based on libcurl and libevent
Stars: ✭ 90 (-26.83%)
Mutual labels:  curl
Curl To Go
Convert curl commands to Go code in your browser
Stars: ✭ 1,372 (+1015.45%)
Mutual labels:  curl
Http Client
A high-performance, high-stability, cross-platform HTTP client.
Stars: ✭ 86 (-30.08%)
Mutual labels:  curl
Notebook
我的技术笔记本~
Stars: ✭ 118 (-4.07%)
Mutual labels:  curl
Okurl
OkHttp Kotlin command line
Stars: ✭ 77 (-37.4%)
Mutual labels:  curl
Grawler
Grawler is a tool written in PHP which comes with a web interface that automates the task of using google dorks, scrapes the results, and stores them in a file.
Stars: ✭ 98 (-20.33%)
Mutual labels:  curl
React Native Vdebug
React-Native 调试工具,支持Console终端、Network导出cURL,可视化Response,Retry cURL。
Stars: ✭ 124 (+0.81%)
Mutual labels:  curl
Walkman
Write HTTP requests in Org mode and replay them at will using cURL
Stars: ✭ 120 (-2.44%)
Mutual labels:  curl
Mpdas
MPD AudioScrobbler written in C++ using libcurl
Stars: ✭ 101 (-17.89%)
Mutual labels:  curl

Introduction

Measures time-to-first-byte for single or multiple URLs. Can show you quickest, slowest & median TTFB values plus optionally log all response headers.

Sample run of ttfb.sh

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
	-v verbose output. Show response breakdown (DNS lookup, TLS handshake etc)

Implicitly follows a redirection chain using curl's -L option.

Can log all response headers (the default log file is ./curl.log) by calling with -d.

Override the default log file by specifying -l /some/file.

Get quickest, slowest and median TTFB values by specifying the number of times to call a URL; use -n2 for 2 tests, -n5 for 5 and so on.

Uses the calculation %{time_starttransfer¹} - %{time_appconnect²} which doesn't include any connection overhead, to better approximate devtool’s TTFB figure.

¹ time_starttransfer

The time, in seconds, it took from the start until the first byte was just about to be transferred. This includes time_pretransfer and also the time the server needed to calculate the result.

² time_appconnect

The time, in seconds, it took from the start until the SSL/SSH/etc connect/handshake to the remote host was completed.

Genesis

Based on a gist by https://github.com/sandeepraju

Modified by [email protected], @jaygooby

Usage

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
	-v verbose output. Show response breakdown (DNS lookup, TLS handshake etc)

Examples

Basic usage:

$ ttfb example.com
.227436

Basic usage with verbose response breakdown:

$ ttfb -v https://example.com
DNS lookup: 0.005152 TLS handshake: 0.000000 TTFB including connection: 0.200831 TTFB: .200831 Total time: 0.201132

Test multiple times:

$ ttfb -n 5 example.com/example/url
.....
fastest .177263 slowest .214302 median .179957

Test multiple URLs:

$ ttfb bbc.co.uk news.bbc.co.uk
bbc.co.uk        .049985
news.bbc.co.uk   .054122

Test multiple URLs, multiple times:

$ 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

Verbose response breakdown when multiple tests specified:

$ 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

Log all the response headers for multiple tests to multiple URLs:

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

More detail on time-to-first-byte

See https://blog.cloudflare.com/a-question-of-timing/ and https://curl.haxx.se/docs/manpage.html for an explanation of how the curl variables relate to the various stages of the transfer.

Diagram showing what each of the curl variable timings refer to against a typical HTTP over TLS 1.2 connection

To get a better approximation of devtool's TTFB, we consider the time without the connection overhead: %{time_starttransfer} - %{time_appconnect}

Uses a dirty eval to do the ttfb arithmetic. Depends on bc and column commands.

TODO

  • [x] Show progress when more than one request (-n 2 etc) option is set

  • [ ] Sort output by fastest TTFB when multiple URLs are supplied

  • [ ] Colour code the TTFB: figure in the standard response, according to the speed of the response.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].