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 🙏

© 2026 – Pkg Stats / Ryan Hefner

profiling-decorator

v1.1.4

Published

Runtime arguments profiling as ES7 decorators.

Readme

profiling-decorator

Installation

Use the following command in order to install this module

npm install profiling-decorator

This use v8-profiler and v8-natives as dependencies.

Webpack support

If you want use this module with the webpack module bundler, you have to set the following configuration in webpackConfig.js file :

plugins: [
  new webpack.IgnorePlugin(/\bv8-profiler\b/),
],
resolve: {
  alias: {
    'v8-natives': 'v8-natives/lib/v8-browser-all',
  },
},

Usage

There are several decorators available :

  • @profiling This feature only works server-side. It allows to decorate a function in order to generate a CPU profiling file that starts before calling function and then stops at the end of execution. The generated file will be saved in a specific folder: profiling. Finally you can inspect the generated file with the amazing DevTools from google.
Example
import { profiling } from 'profiling-decorator';

// Decorate your function
@profiling()
foo() {
  console.log('bar');
}

// Then run your function
foo();

A file will be generated :

.cpuprofile

You can also decorate regular function :

// Decorate your regular function
const foo = profiling(() => {
  console.log('bar');
});

// Then run your function
foo();

You will see a file generated with default name :

.cpuprofile

If you want set a specific name, just use :

// Decorate your regular function
const foo = profiling(() => {
  console.log('bar');
}, 'SpecificName');

// Or ...
@profiling('SpecificName')
foo() {
  console.log('bar');
}
// Then run your function
foo();

You will see your specific named file :

.cpuprofile

  • @optimize This feature works server-side and client-side. It allows to decorate a function in order to show if this function is optimized or not using the v8 functions. I advise you to watch this article. When you will decorate a function, you have to run at least 3 times this function before you can see whether the function is optimized or not.
Example

You can use it like @profiling :

import { optimize } from 'profiling-decorator';

// Decorate your regular function
const foo = optimize(() => {
  console.log('bar');
}, 'SpecificName');

// Or ...
@optimize('SpecificName')
foo() {
  console.log('bar');
}
// Then run several times (at least 3) your function
foo();
foo();
foo();

You have to run your node application or your browser with the following opts command in order to active natives v8 functions :

// Node
node --allow-natives-syntax [path-to-app]

// Chrome (be sure to shutdown all chrome process before doing this)
chrome  --js-flags=--allow-natives-syntax

This will be output a log like :

.optimize

If you want more information about the optimization process, you can run the following command (only server-side) :

node --trace_opt --trace_deopt --allow-natives-syntax [path-to-app] | grep --context=5 [regexp-function-name]

This will output more logs from --trace-opt & --trace-deopt options that will tell you why your function were not optimized.

// Not optimized function (try/catch)
const foo = optimize(() => {
  try {
    console.log('bar');
  }
  catch(e) {
    console.log(e);
  }
}, 'SpecificName');

You can see the reason about the not optimized function :

.optimize