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

@ramitos/cpuprofilify

v1.0.0

Published

Converts output of various profiling/sampling tools to the .cpuprofile format so it can be loaded into Chrome DevTools.

Downloads

10

Readme

cpuprofilify build status

testling badge

Converts output of various profiling/sampling tools to the .cpuprofile format so it can be loaded into Chrome DevTools.

screenshot

Table of Contents generated with DocToc

Installation

npm install -g cpuprofilify

Instructions

cpuprofilify installs two binary scripts:

  • profile_1ms.d: DTrace script that samples your process, use either of the following to generate a trace
    • sudo profile_1ms.d -c <command> | cpuprofilify > out.cpuprofile
    • sudo profile_1ms.d -p <process id> | cpuprofilify > out.cpuprofile
  • cpuprofilify: which will convert a perf or DTrace trace into a .cpuprofile importable into Chrome DevTools

Example

using DTrace script

# In Terminal A
➝  sudo profile_1ms.d -c 'node --perf-basic-prof example/fibonacci' | \
      cpuprofilify > /tmp/example.cpuprofile
pid <process-pid>
HTTP server listening on port 8000

# In Terminal B
➝  ab -n 6 -c 2 http://:::8000/1000/
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking :: (be patient).....done
[ .. ]

➝  sudo kill <process-pid>

Now open /tmp/example.cpuprofile in Chrome DevTools Profiles - Load

NOTE: in order to try the above example please clone this repository.

Usage

cat trace.txt | cpuprofilify <options> > my.cpuprofile 

  Converts the given trace taking according to the given opttions


OPTIONS:

--unresolveds  , --nounresolveds    unresolved addresses like `0x1a23c` are filtered from the trace unless this flag is set (default: false)
--sysinternals , --nosysinternals   sysinternals like `__lib_c_start...` are filtered from the trace unless this flag is set (default: false)
--v8internals  , --nov8internals    v8internals like `v8::internal::...` are filtered from the trace unless this flag is set (default: false)
--v8gc         , --nov8gc           when v8internals are filtered, garbage collection info is as well unless this flag set  (default: true)

--shortStack      , --noshortStack        stacks that have only one line are ignored unless this flag is set (default: false)
--optimizationinfo, --nooptimizationinfo  JS optimization info is removed unless this flag is set (default: false)


--type                              type of input `perf|dtrace|instruments`. If not supplied it will be detected. 
--help                              print this help

EXAMPLE:

  Generate cpuprofile from DTrace data with default options 
  using higher switchrate in order to deal with large amount of data being emitted

    sudo profile_1ms.d -x switchrate=1000hz  -c <command> | cpuprofilify > out.cpuprofile

  Generate cpuprofile from DTrace data with default options keeping v8 internals

    sudo profile_1ms.d -c <command> | cpuprofilify --v8internals > out.cpuprofile

  Generate cpuprofile from DTrace data with default options filtering v8 gc events
    
    sudo profile_1ms.d -c <command> | cpuprofilify --nov8gc > out.cpuprofile

cpuprofilify and perf

use this on any system that doesn't have DTrace, but perf instead like Linux

perf record -e cycles:u -g -- node --perf-basic-prof myapp.js
perf script | cpuprofilify > out.cpuprofile

API

generated with docme

License

MIT