New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

code-stopwatch

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code-stopwatch

Simple, lightweight execution timer with named steps

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

Simple Execution Timer

Lightweight execution timer for Node.js with named steps. Track execution time between different parts of your code with minimal overhead.

Install

npm install code-stopwatch

Usage

const { Timer } = require('simple-execution-timer');
// Create a new timer
const timer = new Timer('MyProcess');
// Mark different steps in your code
timer.mark('Step 1'); // Returns: { sinceLast: 1.2, sinceStart: 1.2 }
timer.mark('Step 2'); // Returns: { sinceLast: 0.5, sinceStart: 1.7 }
// End timing and get total duration
const total = timer.end(); // Returns total seconds elapsed

Options

const timer = new Timer('MyProcess', { silent: true }); // Disables console output

API

new Timer(name, options?)

  • name: String identifier for the timer
  • options: Configuration object
    • silent: Boolean (default: false) - Suppress console output

timer.mark(label)

Marks a point in time and returns timing information

  • Returns: { sinceLast: number, sinceStart: number } (times in seconds)

timer.end()

Stops the timer and returns total duration

  • Returns: number (total seconds elapsed)

License

MIT

Keywords

timer

FAQs

Package last updated on 15 Jan 2025

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