{"name":"0x","version":"5.5.0","author":{"name":"David Mark Clements"},"license":"MIT","_id":"0x@5.5.0","maintainers":[{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"davidmarkclements","email":"david.mark.clements@gmail.com"}],"homepage":"https://github.com/davidmarkclements/0x#readme","bugs":{"url":"https://github.com/davidmarkclements/0x/issues"},"bin":{"0x":"cmd.js"},"dist":{"shasum":"3ed8cd6d3021e62628e7f778b16f08b90717edda","tarball":"http://registry-npm.ywwl.com/0x/download/0x-5.5.0.tgz","fileCount":44,"integrity":"sha512-5w4bEfUtEffy1uO5tf8vF8QRK6nAXPrZ6p/7u2clSf1PDFkZHkh9Cj/m1L5mvlLpyWnl9Ld6SCKPC/eAJMyzpA==","signatures":[{"sig":"MEUCIBwQSr1LfQtV7kT+e5ftQF12efxHfQg4xOQ9+Pk7WleFAiEA6ButYCZ6yJIhpL6OWOxD3q8Hjvs+b0N1pdPz0B4O1zw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":101778,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkBc3gACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoE5Q/6AiST1O228seSBzgBCuRHSvYI4Vr7tr/Mjm2P4aKGEg+4g52o\r\nhVpquqa/mnGBQoBLkROJzBws3s9tzfC5ZlwPF4zC4MoSHvTXMWrBUG1M+sZr\r\nam8WgQ94DFBAmzgPBBrBPUoZ53nez9V6wx9TCGIQ3Yh039acM/sVXusgaMCF\r\nlqADqOK95eCEqByvGBTE3h5TfdiS8UM7U+5WAA3DkKTb4kHVOJ0slQBXZ5P0\r\nh3zysC8M8AM8YS5+Zs/MpVEjJAB5JtNeSY4q40xqMB4kyiQ5PiTDG2kIXLkC\r\nlHcBF2pnO+q9p6t2hMIWRjLR9qvLr11J2XDOicPdfjms57XrNBdItbFkoEbl\r\nHjC910LEwZsPox3K5bHZpyRe4nURAuXiiuiCaNHFCfvZzVCVAI8655VJuVAZ\r\ntgOEfuYIoxdpbMuw9Gcxg/BbI3JNHaoUznfKBEvEb2NXyukt0PWPljeeuvM2\r\nwM17CAEChdPnKWEAHGvcidAhThiFrdxojuaHvyrVzHcrWIrOQtF7tidUt8Vm\r\nhtpphdxTDZlUvj4JW7hy0dXvq6Zjl5wNarTPtXucK+F4KSFKItETpwZj8Faa\r\nuLPTRtPx42uaf6kRyVejtPO4fzzdNoLSZOHpo+D2/xqaHfmWErCOvXvG+xZd\r\nUwX+JxfIHywW27N8AF+e8UfJOwjmAnQgrsU=\r\n=33cA\r\n-----END PGP SIGNATURE-----\r\n","size":33179,"noattachment":false,"key":"/0x/-/0x-5.5.0.tgz"},"main":"index.js","engines":{"node":">=8.5.0"},"gitHead":"8d34f06bce33c287e6e50ee602ef4b1b55175101","scripts":{"lint":"standard --fix | snazzy","test":"npm run lint && tap test/*.test.js","start":"./cmd.js --on-port 'npm run stress-rest-example' -- node examples/rest-api","stress-rest-example":"cd examples/rest-api && npm test"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"repository":{"url":"git+https://github.com/davidmarkclements/0x.git","type":"git"},"_npmVersion":"9.3.1","description":"🔥 single-command flamegraph profiling 🔥","directories":{},"_nodeVersion":"18.14.1","dependencies":{"ajv":"^8.8.2","opn":"^5.4.0","pump":"^3.0.0","d3-fg":"^6.14.0","debug":"^4.1.1","which":"^2.0.2","semver":"^7.3.5","split2":"^4.0.0","pumpify":"^2.0.1","debounce":"^1.2.0","fs-extra":"^10.1.0","make-dir":"^3.1.0","minimist":"^1.2.0","morphdom":"^2.3.3","nanohtml":"^1.4.0","tachyons":"^4.9.1","through2":"^4.0.0","execspawn":"^1.0.1","browserify":"^17.0.0","env-string":"^1.0.0","has-unicode":"^2.0.1","jsonstream2":"^3.0.0","concat-stream":"^2.0.0","end-of-stream":"^1.1.0","on-net-listen":"^1.1.0","single-line-log":"^1.0.1","escape-string-regexp":"^4.0.0","hsl-to-rgb-for-reals":"^1.1.0"},"_hasShrinkwrap":false,"browserify-shim":{},"devDependencies":{"tap":"^15.0.0","rimraf":"^3.0.2","snazzy":"^9.0.0","standard":"^16.0.0"},"_npmOperationalInternal":{"tmp":"tmp/0x_5.5.0_1678101984331_0.16602230202876966","host":"s3://npm-registry-packages"},"readme":"# 0x\n\n<img alt=0x src=assets/0x-logo.png width=350>\n\n🔥 single-command flamegraph profiling 🔥\n\nDiscover the bottlenecks and hot paths in your code, with flamegraphs.\n\n## Visualize Stack Traces\n\n`0x` can profile and generate an interactive flamegraph for a Node process with a single command,\non any platform which Node runs on (macOs, Linux, Windows, Android...).\n\n## Support\n\n* Node v20.x and above\n* Default usage supports any Operating System that Node runs on!\n* Chrome\n  * Other browsers may open flamegraphs in a degraded, but functional form\n\n## Install\n\n```sh\nnpm install -g 0x\n```\n\n## Usage\n\nUse `0x` to run a script:\n\n```sh\n0x my-app.js\n```\n\nImmediately open the flamegraph in the browser:\n\n```sh\n0x -o my-app.js\n```\n\nAutomatically execute profiling command against the first\nport opened by profiled process:\n\n```sh\n0x -P 'autocannon localhost:$PORT' my-app.js\n```\n\nUse a custom node executable:\n\n```sh\n0x -- /path/to/node my-app.js\n```\n\nPass custom arguments to node:\n\n```sh\n0x -- node --zero-fill-buffers my-app.js\n```\n\n> for pwsh users, switch to CMD at first or run with `npx` \n> \n```\nnpx 0x -o my-app.js\n```\n\n## Generating\n\nWhen ready to generate a flamegraph, send a SIGINT or a SIGTERM.\n\nThe simplest way to do this is pressing CTRL+C.\n\nWhen `0x` catches the SIGINT or the SIGTERM, it process the stacks and\ngenerates a profile folder (`<pid>.0x`), containing `flamegraph.html`.\n\n## The UI\n\nThe `flamegraph.html` file contains the 0x UI, which is explained in\n[docs/ui.md](docs/ui.md).\n\n## Production Servers\n\nA lightweight, production server friendly, approach to generating a\nflamegraph is described in [docs/production-servers.md](docs/production-servers.md).\n\n## The Profile Folder\n\nBy default, a Profile Folder will be created and named after the PID, e.g.\n`3866.0x` (we can set this name manually using the `--output-dir` flag).\n\nThe Profile Folder is explained in more detail in [docs/profile-folder.md](docs/profile-folder.md)\n\n## Example\n\nClone this repo, run `npm i -g` and from the repo root run\n\n```sh\n0x examples/rest-api\n```\n\nIn another tab run\n\n```sh\nnpm run stress-rest-example\n```\n\nTo put some load on the rest server, once that's done\nuse ctrl + c to kill the server.\n\n## Command Line API\n\n### --help | -h\n\nPrint usage info.\n\n### --open | -o\n\nOpen the flamegraph in the browser using `open` or `xdg-open` (see\nhttps://www.npmjs.com/package/open for details).\n\n### --on-port | -P\n\nRun a given command and then generate the flamegraph.\nThe command as specified has access to a `$PORT` variable.\nThe `$PORT` variable is set according to the first port that\nprofiled process opens.\n\nFor instance, here's an example of using [autocannon](http://npm.im/autocannon)\nto load-test the process:\n\n```sh\n0x -P 'autocannon localhost:$PORT' app.js\n```\n\nWhen the load-test completes, the profiled processed will be\nsent a SIGINT and the flamegraph will be automatically generated.\n\nRemember to use single quotes to avoid bash interpolation,\nor else escape variable (e.g. `0x -P \"autocannon localhost:$PORT\" app.js`\nwon't work wheras `0x -P \"autocannon localhost:\\$PORT\" app.js` will).\n\nNote: On Windows interpolation usually occurs with `%PORT%`, however\nin this case the dollar-prefix `$PORT` is the correct syntax\n(because the interpolation is not shell based).\n\nDefault: ''\n\n### --name\n\nThe name of the HTML file, without the .html extension\nCan be set to - to write HTML to STDOUT (note\ndue to the nature of CLI argument parsing, this must be set using `=`,\ne.g. `--name=-`).\n\nIf either this flag or `--output-html-file` is set to `-`\nthen the HTML will go to STDOUT.\n\nDefault: flamegraph\n\n### ---title\n\nSet the title to display in the flamegraph UI.\n\nDefault: the command that 0x ran to start the process\n\n### --output-dir | -D\n\nSpecify artifact output directory. This can be specified in template\nform with possible variables being `{pid}`, `{timestamp}`, `{name}`\n(based on the `--name` flag) and `{outputDir}`(variables\nmust be specified without whitespace, e.g. `{ pid }` is not supported).\n\nDefault: `{pid}.0x`\n\n### --output-html | -F\n\nSpecify destination of the generated flamegraph HTML file.\nThis can be specified in template form with possible variables\nbeing `{pid}`, `{timestamp}`, `{name}` (based on the `--name` flag) and\n`{outputDir}` (variables must be specified without whitespace,\ne.g. `{ pid }` is not supported). It can also be set to `-` to\nsend the HTML output to STDOUT (note\ndue to the nature of CLI argument parsing, this must be set using `=`,\ne.g. `--output-html=-`).\n\nIf either this flag or `--name` is set to `-`\nthen the HTML will go to STDOUT.\n\nDefault: `{outputDir}/{name}.html`\n\n### --kernel-tracing\n\nUse an OS kernel tracing tool (perf on Linux). This will capture\nnative stack frames (C++ modules and Libuv I/O),\nbut may result in missing stacks from Node.js due to the optimizing compiler.\n\nSee [docs/kernel-tracing.md](docs/kernel-tracing.md) for more information.\n\nDefault: false\n\n### --quiet | -q\n\nLimit output, the only output will be fatal errors or\nthe path to the `flamegraph.html` upon successful generation.\n\nDefault: false\n\n### --silent | -s\n\nSuppress all output, except fatal errors.\n\nDefault: false\n\n### --collect-only\n\nDon't generate the flamegraph, only create the Profile Folder,\nwith relevant outputs.\n\nDefault: false\n\n### --collect-delay\n\nDelay the collection of stacks by a specified time(ms) relative to the first entry.\n\nDefault: 0\n\n### --visualize-only\n\nSupply a path to a profile folder to build or rebuild visualization\nfrom original stacks.\n\nDefault: undefined\n\n### --visualize-cpu-profile\n\nSupply a path to a CPU profile (`.cpuprofile`). See `examples/cpu-profile` for examples.\n\n[CPU Profile](https://developers.google.com/web/tools/chrome-devtools/rendering-tools/js-execution) output does not have as much information but it can be exported from Chrome Devtools in the browser. There's also an automated headless tool for doing so: [automated-chrome-profiling](https://github.com/paulirish/automated-chrome-profiling). For creating Node.js Cpu Profiles in Node see [v8-profiler](https://github.com/node-inspector/v8-profiler) or [v8-profiler-next](https://github.com/hyj1991/v8-profiler-next). They can also be generated from Node.js 12 and above using the command-line flag [`--cpu-prof`](https://github.com/nodejs/node/commit/e0e308448240260c207958dfc3dd9245d903af85).\n\nDefault: undefined\n\n### --kernel-tracing-debug\n\nShow output from perf(1) tools.\n\nDefault: false\n\n### --tree-debug\n\nSave the intermediate tree representation of captured trace output to a JSON\nfile.\n\nDefault: false\n\n## Programmatic API\n\n0x can also be required as a Node module and scripted:\n\n```js\nconst zeroEks = require('0x')\nconst path = require('path')\n\nasync function capture () {\n  const opts = {\n    argv: [path.join(__dirname, 'my-app.js'), '--my-flag', '\"value for my flag\"'],\n    workingDir: __dirname\n  }\n  try {\n    const file = await zeroEks(opts)\n    console.log(`flamegraph in ${file}`)\n  } catch (e) {\n    console.error(e)\n  }\n}\n\ncapture()\n\n```\n\nThe Programmatic API is detailed in [docs/api.md](docs/api.md).\n\n## Troubleshooting\n\n### Memory Issues\n\nVery complex applications with lots of stacks may hit memory issues.\n\nThe `--stack-size` flag can be used to set the memory to the maximum 8GB\nin order to work around this when profiling:\n\n```\nnode --stack-size=8024 $(which 0x) my-app.js\n```\n\nThere may still be a problem opening the flamegraph in Chrome. The same work\naround can be used by opening Chrome from the command line (platform dependent)\nand nesting the `--stack-size` flag within the `--js-flags` flag:\n`--js-flags=\"--stack-size 8024\"`.\n\n## Debugging\n\n`DEBUG=0x* 0x my-app.js`\n\n## Alternatives\n\n* <https://github.com/brendangregg/FlameGraph> (perl)\n* <https://www.npmjs.com/package/stackvis> (node)\n* <https://www.npmjs.com/package/d3-flame-graph> (node)\n\n## Acknowledgements\n\nThe original sponsor of this work was [nearForm](http://nearform.com)\n\nThis tool is inspired from various info and code sources\nand would have taken much longer without the following people and\ntheir Open Source/Info Sharing efforts:\n\n* Thorsten Lorenz (<http://thlorenz.com/>)\n* Dave Pacheco (<http://dtrace.org/blogs/dap/about/>)\n* Brendan Gregg (<http://www.brendangregg.com/>)\n* Martin Spier (<http://martinspier.io/>)\n\n## License\n\nMIT\n","publish_time":1678101984516,"_cnpm_publish_time":1678101984516,"dist-tags":{"latest":"6.0.0","rc1":"4.0.0-rc1","rc2":"4.0.0-rc2","rc3":"4.0.0-rc3","rc4":"4.0.0-rc4","rc5":"4.0.0-rc5","v2-latest":"2.5.4","v3-latest":"3.3.1"}}