New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

debugging-timer

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

debugging-timer

Measure the execution time of multiple sections of your code, then effortlessly print all the timer results at once to the console.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-87.5%
Maintainers
1
Weekly downloads
 
Created
Source

Debug Timer: benchmark the performance of multiple parts of your code

Measure the duration of multiple parts of your code, then effortlessly print all the timer results at once to the console.

What you get

Sample output:

Loading file: 506 ms
Processing data: 858 ms

How to get it

You will use three methods: timer.start('task name'), timer.end('task name'), and timer.print() to show the results in the console. The print() method also returns the results as string, so you can save it to some logs if you need.

const DebugTimer = require('debugging-timer');
let timer = new DebugTimer();

(async () => {
	timer.start('Loading file');
	// Let's pretend we are doing some work here:
	await delay(500);
	timer.end('Loading file');	

	timer.start('Processing data');
	await delay(850);
	timer.end('Processing data');
	
	// Let's see the results!
	timer.print();

	// Prints:
	// Loading file: 506 ms
	// Processing data: 858 ms
})();

async function delay(ms) {
	await new Promise(resolve => setTimeout(resolve, ms));
}

Questions and feedback

Welcome in the linked GitHub repository.

Keywords

FAQs

Package last updated on 12 Jul 2018

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