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

perf-chk

v1.0.5

Published

Check your code perfomance in Node.js

Downloads

2

Readme

perf-chk (Performance Check)

Why did you make perf-chk?

I'm interested in code execution time,
So I sometimes test my code,
then I use below code.

const iterations = 10000000;
console.time("function A");
for(let i=0; i<iterations; i++){
  // some code1
}
console.timeEnd("function A"); // 'Function A: xxx.xxx ms'
console.time("function B");
for(let i=0; i<iterations; i++){
  // some code2
}
console.timeEnd("function B"); // 'Function B: xxx.xxx ms'

but I can't remember upper code.
So I copy & paste upper code,
and edit many code(function name, code, iteration count).
It is very annoying... so I made perf-chk!

What is perf-chk?

It is execution time checker in Node.js.
Use perf-chk if you want to know which code is faster.

Getting Started

perf-chk uses some ES6 features. (const, arrow function)
So you must use Node.js v6.4.0 or more.

Installation

  • global (recommended)
npm i -g perf-chk
  • local
npm i -D perf-chk

Usage

1. make your test code. (module)

// some code
// blahblah

module.exports = {
  methodA: function() { // ES5 function syntax
    // blahblah
  },
  methodB() { // ES6 Method syntax
    // blahblah
  },
  methodC: () => { // ES6 Arrow Function syntax
    // blahblah
  }
}
note
  • module.exports = {} is module export syntax in node.js.
    and perf-chk is node.js app, so you must use this syntax.
  • You can choose function syntax

2. check execution time

  1. open terminal(cmd in windows)
  2. type below,
perf-chk {module_name} [iteration_counts]

If you installed it locally, type below

./node_modules/perf-chk {module_name} [iteration_counts]

usage

note

module_name is required, and module_name is <filename>.js or <filename>
iteration_counts is optional, default value is 100,000,000.
iteration_counts range is safe integer for natural number.
range is 1 ~ 9,007,199,254,740,991.
if the execution time of functions are similar,
There is no difference between them,
but you want to know diffrence of execution time,
you have to extend iteration_counts

Notes

  • Execution time isn't same.
    It depends on Computer specification(CPU, RAM, etc.)
    And same computer's result isn't same.
    Because CPU and RAM usage is Vary every time.
    So use execution time for reference only.
  • perf-chk runs on Node.js
    Node.js not contains DOM(Document Object Model, like document.getElementById),
    and BOM(Browser Object Model, like window.alert).
    So you can test only ECMAScript,
    ECMAScript version supporting is dependent on the Node.js version.
    Go to below link if you want to know Node.js ES Support table.
    Node.js ECMAScript compatibility tables