#web-performance #performance #http-request #timing #http #http-status #web

http-timings

A simple library to measure the key HTTP timings from the development tools

4 releases

new 0.1.4 Oct 25, 2024
0.1.3 Aug 24, 2024
0.1.2 Apr 15, 2024
0.1.1 Apr 12, 2024
0.1.0 Apr 12, 2024

#1749 in Web programming

Download history 21/week @ 2024-07-29 155/week @ 2024-08-19 20/week @ 2024-08-26 15/week @ 2024-09-16 5/week @ 2024-09-23 11/week @ 2024-09-30 1/week @ 2024-10-07 100/week @ 2024-10-21

112 downloads per month

Custom license

18KB
391 lines

http-timings: A library to measure HTTP timings

Inspired by the TTFB library by phip1611. The HTTP timings provided by this library are as follows:

  • DNS Lookup Time
  • TCP Connection Time
  • TLS Handshake Time
  • HTTP Send Time
  • Time to First Byte
  • Content Download Time

As well as this timing, this library also provides the following information about each request:

  • HTTP Status Code
  • Body of the response

Usage

use http_timings::request_url;

if let Ok(timings) = request_url("https://www.google.com") {
   println!("{:?}", timings);
}

/// Output:
/// RequestOutput {
///   status: 200,
///   timings: RequestTimings {
///     dns: 19.121396ms,
///     tcp: 42.066481ms,
///     tls: Some(29.665676ms),
///     http_send: 8.977µs,
///     ttbf: 101.531718ms,
///     content_download: 2.268473ms
///   },
///   body: "<!doctype html>..."
/// }

The RequestOutput struct provides the timings in both relative and total terms. The relative timings are the time taken for each step of the request, while the total timings are the time taken from the start of the request to the end of the request.

The URL input can be any valid website as well as any valid IP.

Dependencies

~15–23MB
~574K SLoC