Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@szmarczak/http-timer

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@szmarczak/http-timer

Timings for HTTP requests

  • 5.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13M
decreased by-15.11%
Maintainers
1
Weekly downloads
 
Created

What is @szmarczak/http-timer?

@szmarczak/http-timer is an npm package designed to measure the timing of HTTP requests. It provides detailed timing information for various phases of an HTTP request, such as DNS lookup, TCP connection, and response time. This can be useful for performance monitoring and debugging.

What are @szmarczak/http-timer's main functionalities?

Measure HTTP request timings

This feature allows you to measure the timings of an HTTP request. The code sample demonstrates how to use the package to measure and log the timings of a GET request to 'http://example.com'.

const http = require('http');
const timer = require('@szmarczak/http-timer');

const request = http.get('http://example.com', response => {
  timer(request);
  response.on('end', () => {
    console.log(request.timings);
  });
});

Detailed timing phases

This feature provides detailed timing information for different phases of an HTTP request. The code sample shows how to log the DNS lookup time, TCP connection time, time to first byte, download time, and total time for a GET request.

const http = require('http');
const timer = require('@szmarczak/http-timer');

const request = http.get('http://example.com', response => {
  timer(request);
  response.on('end', () => {
    console.log('DNS Lookup Time:', request.timings.dns);
    console.log('TCP Connection Time:', request.timings.tcp);
    console.log('First Byte Time:', request.timings.firstByte);
    console.log('Download Time:', request.timings.download);
    console.log('Total Time:', request.timings.total);
  });
});

Other packages similar to @szmarczak/http-timer

Keywords

FAQs

Package last updated on 20 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc