npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

profilator

v1.2.0

Published

Zero dependency tool to measure time spent in JavaScript code

Downloads

7

Readme

profilator

Zero dependency tool to measure time spent in JavaScript code. You can start and stop each label many times, and profilator will internally save each time sample and present a complete report of where you spent your time.

Installation

npm install profilator

How to use

Taking samples

Start and stop each fraction of the code you want to measure and / or compare with other parts, with a label for each one:

const buildProfilator = require("profilator");
const profilator = buildProfilator("My big test"); // You can provide a name for the profilator instance
// or
const profilator = require("profilator")(); // if you intend to use only one

profilator.start("set-up");
// ... Any set-up related code
profilator.stop("set-up");

profilator.start("db tasks");
// ... Some code interacting with your DB
profilator.stop("db tasks");

profilator.start("io tasks");
// ... Maybe reading some files
profilator.stop("io tasks");

profilator.start("db tasks");
// ... Some more DB related code
profilator.stop("db tasks");

profilator.start("io tasks");
// ... And now maybe writing some files
profilator.stop("io tasks");

Check how it's going

At any point in time you can check the total time spent for any given label, or all of them:

Reporting / showing results

After all your samples are taken, you can get a report of where you spent all your time.

const resultsReport = profilator.buildResultsReport();
console.log(resultsReport);

This would print this report, ordered by time spent

# Profilator session: My big test
TOTAL TIME          1000 ms
db tasks            800 ms (80 %)
io tasks            130 ms (13 %)
set-up              70 ms (7 %)

Each line will display the first 20 characters of the label, any longer one will be truncated.