Skip to content

Commit b9fc5d1

Browse files
committed
Add documentation for CLI usage
1 parent 9939d90 commit b9fc5d1

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

README.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![Coverage](https://img.shields.io/codecov/c/github/JoshCrozier/https-timer.svg?style=flat-square)](https://codecov.io/github/JoshCrozier/https-timer)
88
[![Vulnerabilities](https://snyk.io/test/npm/https-timer/badge.svg?style=flat-square)](https://snyk.io/test/npm/https-timer)
99

10-
A lightweight, dependency-free [Node.js]((https://nodejs.org)) module for timing HTTP/HTTPS requests.
10+
A lightweight, dependency-free [Node.js](https://nodejs.org) module for timing HTTP/HTTPS requests.
1111

1212
Useful for determining the duration of different HTTPS phases:
1313

@@ -85,6 +85,8 @@ The `get` and `request` methods also have async equivalents: `getAsync` and `req
8585
Promise usage:
8686

8787
```js
88+
const httpsTimer = require('https-timer');
89+
8890
httpsTimer.getAsync('https://www.google.com').then(response => {
8991
console.log(response.timing);
9092
});
@@ -93,14 +95,42 @@ httpsTimer.getAsync('https://www.google.com').then(response => {
9395
Async/Await usage:
9496

9597
```js
98+
const httpsTimer = require('https-timer');
99+
96100
const response = await httpsTimer.getAsync('https://www.google.com');
101+
97102
console.log(response.timing);
98103
```
99104

100105
For more detailed examples with error handling, see the [examples directory](https://github.com/JoshCrozier/https-timer/tree/master/examples).
101106

107+
## Command-Line Usage
108+
109+
If you prefer to time requests directly from the command-line with preformatted output, you can alternatively install the [time-request](https://github.com/JoshCrozier/time-request) package:
110+
111+
$ npm install -g time-request
112+
113+
Usage:
114+
115+
$ time-request https://google.com
116+
117+
Example Output:
118+
119+
```
120+
Request Phase Duration
121+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122+
Socket Open 1.61 ms
123+
DNS Lookup 34.15 ms
124+
TCP Connection 47.69 ms
125+
TLS Handshake 102.25 ms
126+
Time to First Byte 67.23 ms
127+
Content Transfer 1.69 ms
128+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
129+
Total 254.62 ms
130+
```
131+
102132
## License
103133

104-
[MIT License](http://opensource.org/licenses/MIT)
134+
[MIT License](https://opensource.org/licenses/MIT)
105135

106-
Copyright (c) 2016-2018 Josh Crozier
136+
Copyright (c) 2016-2019 Josh Crozier

0 commit comments

Comments
 (0)