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

nodprof

v0.1.3

Published

profiling for node.js using v8 natives

Downloads

16

Readme

nodprof - profiling for node.js

nodprof command line

The nodprof command can be used to:

  • run a node.js module and profile the execution
  • start an HTTP server used to display profiling results

When profiling a node.js module, the profiling results will be stored in a JSON file in a directory indicated by the nodprof configuration.

The nodprof HTTP server provides a viewer for these profiling results. You can also use the nodprof module API to add the nodprof viewer to your own application via middleware.

To run the server, use the --serve option. If the --serve option isn't used then nodprof will run the remainder of the command-line as a module invocation and profile the execution.

When profiling a module, profiling will be started, the module will be require()d, and when process emits the exit event, profiling will be stopped and the data written out.

example command line invocation

sudo npm -g install nodprof
nodprof --serve --port 8081&
nodprof `which npm` info grunt
open http://localhost:8081

This will:

  • install nodprof globally
  • start the nodprof server on port 8081
  • profile npm info grunt
  • open a browser to view the results

nodprof configuration

nodprof uses a configuration to determine the values of various twiddleable values it uses. These values can be set in the following places, listed in precedence order:

  • command line options
  • environment variables
  • configuration file values
  • default values

command line options

options specified as Boolean can be specified without a Boolean value, in which case the value is assumed to be true.

environment variables

configuration file values

The configuration file is a JSON file whose content is an object with the following properties:

default values

nodprof module API

The nodprof module provides low-level support for profiling via exported functions. The functions return large JSON-able objects.

nodprof.profileStart()

Start profiling. Does nothing if profiling already started.

Returns nothing.

nodprof.profileStop()

Stop profiling. Does nothing if profiling already stopped.

Returns a ProfileResults object or null if profiling was not started.

nodprof.isProfiling()

Returns true if profiling has been started, else false.

nodprof.heapSnapshot()

Returns a HeapSnapshotResults object.

nodprof.middleware(config)

Returns a function which can be used as connect middleware to provide the function of the command-line nodprof server in your application. The url is the directory-sh uri to mount the functionality under, and defaults to /nodprof.

The config parameter specifies a configuration object, which is the same format as the configuration file specified above.

Example for express:

app.use("/nodprof/", nodprof.middleware())

nodprof object shapes

For more detail on what the values in these objects mean, see the source at https://code.google.com/p/v8/source/browse/trunk/include/v8-profiler.h

ProfilesResult object

ProfilesNode object

HeapSnapshotResults object

HeapNode object

HeapEdge object

nodprof development

If you want to hack on nodprof, the workflow:

  1. clone the git repo
  2. cd into the project directory
  3. run make watch
  4. edit the files in your flavorite editor
  5. when you save files, the code will be rebuilt, and server restarted
  6. generate some profiling data, view in the restarted server

Then iterate on 4, 5, and 6.