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

perflog

v3.0.0

Published

Simple Performance logger for js

Downloads

26

Readme

#PERFLOG

A simple performance logger. No external library. Not tested in production. It can be used for debugging and development environment.

##Syntax

// declarion
     const perf = require("perflog")();
//mark
     perf("apiCall");

##Usage examples

Print log in the console:

    // initialize 
    const perf = require("perflog")();
   
    // mark the point
    perf("apiCall");
    const response = await axios.get();
    // mark again. so between this two perf() calls it logs the time in the console
    perf("apiCall");

If you dont wish to log into the console,

     // initialize 
        const perf = require("perflog")({inLineLog:false});
       
        // mark the point
        perf("apiCall");
        const response = await axios.get();
        // mark again.
        perf("apiCall");

Now console logs wont be there. To get the performance details. The way is using perf._summary

    console.log(perf._summary);

To get all the performance logs :

    perf("apiCall");
    const response = await axios.get();
    // mark again. so between this two perf() calls it logs the time in the console
    perf("apiCall");
    
    perf("db");
    await db.create(data);
    perf("db");

    const summary = perf._summary;
    console.log(summary);

Output:

    {
      "apiCall": "1160.50",
      "db": "1113.13"
    }

##Options:

   const perf = require("perflog")({
       enabled:true,
       inLineLog:true, 
       round:2,
       logPrefix:"PERF:"
   });

| Options | description | | ------------- | ------------- | | enabled | To enable/disable library logging. If set to true, logging will be disabled. Default: true | | inLineLog | DEFAULT:true. if enabled, on the 2nd mark, it will console log the performance. | | round| DEFAULT:2, round off value. | logPrefix| DEFAULT: 'PERF:' |

Environment configuration

####PERF_LOG : If PERF_LOG is set to false, all the logging will be disabled. No in line logging and no logging report in perf._summary object.