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

nprof

v1.1.0

Published

small promise interface to [v8-profiler](https://github.com/node-inspector/v8-profiler) functions

Downloads

22

Readme

nprof

small promise interface to v8-profiler functions

NPM

Code Climate bitHound Code bitHound Dependencies

install

npm i --save nprof

usage

var nprof = require('nprof');

nprof.takeMemorySnapshot('/tmp/snapshots')
    .then((info) => {})
    .catch((error) => {});

nprof.cpuProfile('/tmp/snapshots', 2000)
    .then((info) => {})
    .catch((error) => {});

api

takeMemorySnapshot(snapshotPath, options) : Promise

  • snapshotPath - path to directory (nprof generate filenames)
  • options
    • filepath - set this option with filepath, if you need your own filename

take memory snapshot and save to snapshotPath

filename mask

${snapshotPath}/v8.cpu.2016-09-20T13-56-53-936.cpuprofile'

cpuProfile(snapshotPath, timeout, options) : Promise

  • snapshotPath - path to directory (nprof generate filenames, see)
  • timeout - timeout in ms
  • options
    • filepath - set this option with filepath, if you need your own filepath and filename

start cpu profiling, stop after timeout and save to snapshotPath

filename mask

${snapshotPath}/v8.cpu.2016-09-20T13-56-53-93.timeout.' + timeout + '.cpuprofile'

startCpuProfile()

start cpu profiling

stopCpuProfile() : CpuProfile

stop cpu proflile

saveCpuProfile(profile, snapshotPath, options) : Promise

save profile to file

  • profile - profile object
  • snapshotPath - path to directory (nprof generate filenames)
  • options
    • filepath - set this option with filepath, if you need your own filename

express.js helper

express.js profiling helper

usage


// logger is you logger with info, warn and error methods

var nprofRegister = require('nprof/express/register');

var app = express();

var nprofConfig = {
    snapshotPath: '/tmp/snapshots'
};

nprofRegister(logger, app, nprofConfig);

REST API

POST /_service/profile/cpu?timeout={int}

  • timeout - profile timeout, length of profiling in ms, default = 5000

profile CPU, save to nprofConfig.snapshotPath

POST /_service/profile/cpu/start

start cpu profiling until POST /_profile/cpu/stop not executed

POST /_service/profile/cpu/stop

stop cpu profiling and save to nprofConfig.snapshotPath

POST /_service/profile/mem

take memory snapshot and save to nprofConfig.snapshotPath

GET /_service/profile/mem/usage

scale GET-param can be number or string (kb, mb, gb)

get actual memory usage via process.memoryUsage

POST /_service/profile/gc/start

exec global.gc() if process started with --expose-gc option

return before and after process.memoryUsage

GET /_service/profile/status

return memory usage and event loop delay

you can add your own status metrics via config.statusFn hook function

see examples/status for more information

LICENSE

MIT