{"id":13583766,"url":"https://github.com/thlorenz/cpuprofilify","last_synced_at":"2025-05-07T18:09:23.742Z","repository":{"id":26548008,"uuid":"30001564","full_name":"thlorenz/cpuprofilify","owner":"thlorenz","description":"Converts output of various profiling/sampling tools to the .cpuprofile format so it can be loaded into Chrome DevTools.","archived":false,"fork":false,"pushed_at":"2017-04-20T14:35:08.000Z","size":1628,"stargazers_count":168,"open_issues_count":3,"forks_count":16,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-31T12:57:08.637Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/thlorenz/cpuprofilify","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thlorenz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-29T03:21:28.000Z","updated_at":"2025-03-30T00:41:39.000Z","dependencies_parsed_at":"2022-09-14T04:02:27.801Z","dependency_job_id":null,"html_url":"https://github.com/thlorenz/cpuprofilify","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thlorenz%2Fcpuprofilify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thlorenz%2Fcpuprofilify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thlorenz%2Fcpuprofilify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thlorenz%2Fcpuprofilify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thlorenz","download_url":"https://codeload.github.com/thlorenz/cpuprofilify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252823592,"owners_count":21809705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T15:03:46.227Z","updated_at":"2025-05-07T18:09:23.672Z","avatar_url":"https://github.com/thlorenz.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","DevTools tooling and ecosystem"],"sub_categories":["CPU profile"],"readme":"# cpuprofilify [![build status](https://secure.travis-ci.org/thlorenz/cpuprofilify.png?branch=master)](http://travis-ci.org/thlorenz/cpuprofilify)\n\n[![testling badge](https://ci.testling.com/thlorenz/cpuprofilify.png)](https://ci.testling.com/thlorenz/cpuprofilify)\n\nConverts output of various profiling/sampling tools to the .cpuprofile format so it can be loaded into Chrome DevTools.\n\n![screenshot](assets/cpuprofilify.gif)\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n**Table of Contents**  *generated with [DocToc](https://github.com/thlorenz/doctoc)*\n\n- [Installation](#installation)\n- [Instructions](#instructions)\n- [Example](#example)\n- [Usage](#usage)\n- [cpuprofilify and `perf`](#cpuprofilify-and-perf)\n- [API](#api)\n    - [CpuProfilifier()](#cpuprofilifier)\n    - [CpuProfilifier::convert(trace, opts) → {Object}](#cpuprofilifierconverttrace-opts-→-object)\n- [License](#license)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Installation\n\n    npm install -g cpuprofilify\n\n## Instructions\n\ncpuprofilify installs two binary scripts:\n\n- **`profile_1ms.d`**: DTrace script that samples your process, use either of the following to generate a trace\n  - `sudo profile_1ms.d -c 'node --perf-basic-prof \u003capp\u003e' | cpuprofilify \u003e out.cpuprofile`\n  - `sudo profile_1ms.d -p \u003cprocess id\u003e | cpuprofilify \u003e out.cpuprofile`\n- **`cpuprofilify`**: which will convert a *perf* or *DTrace* trace into a `.cpuprofile` importable into Chrome DevTools\n  - `perf record -e cycles:u -g -- node --perf-basic-prof \u003capp\u003e \u0026\u0026 perf script | cpuprofilify \u003e out.cpuprofile`\n\nUse the `perf record` and `perf script` commands on Linux to generate input to cpuprofilify and the provided\n`profile_1ms.d` script to do so on OSX via dtrace.\n\n## Example\n\n*using DTrace script*\n\n```sh\n# In Terminal A\n➝  sudo profile_1ms.d -c 'node --perf-basic-prof example/fibonacci' | \\\n      cpuprofilify \u003e /tmp/example.cpuprofile\npid \u003cprocess-pid\u003e\nHTTP server listening on port 8000\n\n# In Terminal B\n➝  ab -n 6 -c 2 http://:::8000/1000/\nThis is ApacheBench, Version 2.3 \u003c$Revision: 1554214 $\u003e\nCopyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\nLicensed to The Apache Software Foundation, http://www.apache.org/\n\nBenchmarking :: (be patient).....done\n[ .. ]\n\n➝  sudo kill \u003cprocess-pid\u003e\n```\n\nNow open `/tmp/example.cpuprofile` in Chrome DevTools *Profiles - Load*\n\n**NOTE:** in order to try the above example please clone this repository.\n\n## Usage\n\n```\ncat trace.txt | cpuprofilify \u003coptions\u003e \u003e my.cpuprofile\n\n  Converts the given trace taking according to the given opttions\n\n\nOPTIONS:\n\n--unresolveds  , --nounresolveds    unresolved addresses like `0x1a23c` are filtered from the trace unless this flag is set (default: false)\n--sysinternals , --nosysinternals   sysinternals like `__lib_c_start...` are filtered from the trace unless this flag is set (default: false)\n--v8internals  , --nov8internals    v8internals like `v8::internal::...` are filtered from the trace unless this flag is set (default: false)\n--v8gc         , --nov8gc           when v8internals are filtered, garbage collection info is as well unless this flag set  (default: true)\n\n--shortStack      , --noshortStack        stacks that have only one line are ignored unless this flag is set (default: false)\n--optimizationinfo, --nooptimizationinfo  JS optimization info is removed unless this flag is set (default: false)\n\n\n--type                              type of input `perf|dtrace`. If not supplied it will be detected.\n--help                              print this help\n\nEXAMPLE:\n\n  Generate cpuprofile from DTrace data with default options\n  using higher switchrate in order to deal with large amount of data being emitted\n\n    sudo profile_1ms.d -x switchrate=1000hz  -c \u003ccommand\u003e | cpuprofilify \u003e out.cpuprofile\n\n  Generate cpuprofile from DTrace data with default options keeping v8 internals\n\n    sudo profile_1ms.d -c \u003ccommand\u003e | cpuprofilify --v8internals \u003e out.cpuprofile\n\n  Generate cpuprofile from DTrace data with default options filtering v8 gc events\n\n    sudo profile_1ms.d -c \u003ccommand\u003e | cpuprofilify --nov8gc \u003e out.cpuprofile\n```\n\n## cpuprofilify and `perf`\n\n*use this on any system that doesn't have DTrace, but perf instead like Linux*\n\n```sh\nperf record -e cycles:u -g -- node --perf-basic-prof myapp.js\nperf script | cpuprofilify \u003e out.cpuprofile\n```\n\n## API\n\n\u003c!-- START docme generated API please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN docme TO UPDATE --\u003e\n\n\u003cdiv\u003e\n\u003cdiv class=\"jsdoc-githubify\"\u003e\n\u003csection\u003e\n\u003carticle\u003e\n\u003cdiv class=\"container-overview\"\u003e\n\u003cdl class=\"details\"\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cdl\u003e\n\u003cdt\u003e\n\u003ch4 class=\"name\" id=\"CpuProfilifier\"\u003e\u003cspan class=\"type-signature\"\u003e\u003c/span\u003eCpuProfilifier\u003cspan class=\"signature\"\u003e()\u003c/span\u003e\u003cspan class=\"type-signature\"\u003e\u003c/span\u003e\u003c/h4\u003e\n\u003c/dt\u003e\n\u003cdd\u003e\n\u003cdiv class=\"description\"\u003e\n\u003cp\u003eCreates new CpuProfilifier\u003c/p\u003e\n\u003c/div\u003e\n\u003cdl class=\"details\"\u003e\n\u003cdt class=\"tag-source\"\u003eSource:\u003c/dt\u003e\n\u003cdd class=\"tag-source\"\u003e\u003cul class=\"dummy\"\u003e\n\u003cli\u003e\n\u003ca href=\"https://github.com/thlorenz/cpuprofilify/blob/master/index.js\"\u003eindex.js\u003c/a\u003e\n\u003cspan\u003e, \u003c/span\u003e\n\u003ca href=\"https://github.com/thlorenz/cpuprofilify/blob/master/index.js#L12\"\u003elineno 12\u003c/a\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\n\u003ch4 class=\"name\" id=\"CpuProfilifier::convert\"\u003e\u003cspan class=\"type-signature\"\u003e\u003c/span\u003eCpuProfilifier::convert\u003cspan class=\"signature\"\u003e(trace, \u003cspan class=\"optional\"\u003eopts\u003c/span\u003e)\u003c/span\u003e\u003cspan class=\"type-signature\"\u003e \u0026rarr; {Object}\u003c/span\u003e\u003c/h4\u003e\n\u003c/dt\u003e\n\u003cdd\u003e\n\u003cdiv class=\"description\"\u003e\n\u003cp\u003eConverts the given trace taking according to the given opts.\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003evar cpuprofilifier = require('cpuprofilifier');\nvar cpuprofile = cpuprofilifier().convert(trace);\nfs.writeFileSync('/tmp/my.cpuprofile', JSON.stringify(cpuprofile));\u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\u003ch5\u003eParameters:\u003c/h5\u003e\n\u003ctable class=\"params\"\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eName\u003c/th\u003e\n\u003cth\u003eType\u003c/th\u003e\n\u003cth\u003eArgument\u003c/th\u003e\n\u003cth class=\"last\"\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd class=\"name\"\u003e\u003ccode\u003etrace\u003c/code\u003e\u003c/td\u003e\n\u003ctd class=\"type\"\u003e\n\u003cspan class=\"param-type\"\u003eArray.\u0026lt;String\u003e\u003c/span\u003e\n\u003c/td\u003e\n\u003ctd class=\"attributes\"\u003e\n\u003c/td\u003e\n\u003ctd class=\"description last\"\u003e\u003cp\u003ea trace generated via \u003ccode\u003eperf script\u003c/code\u003e or the \u003ccode\u003eprofile_1ms.d\u003c/code\u003e DTrace script\u003c/p\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"name\"\u003e\u003ccode\u003eopts\u003c/code\u003e\u003c/td\u003e\n\u003ctd class=\"type\"\u003e\n\u003cspan class=\"param-type\"\u003eObject\u003c/span\u003e\n\u003c/td\u003e\n\u003ctd class=\"attributes\"\u003e\n\u0026lt;optional\u003e\u003cbr\u003e\n\u003c/td\u003e\n\u003ctd class=\"description last\"\u003e\n\u003ch6\u003eProperties\u003c/h6\u003e\n\u003ctable class=\"params\"\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eName\u003c/th\u003e\n\u003cth\u003eType\u003c/th\u003e\n\u003cth class=\"last\"\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd class=\"name\"\u003e\u003ccode\u003emap\u003c/code\u003e\u003c/td\u003e\n\u003ctd class=\"type\"\u003e\n\u003cspan class=\"param-type\"\u003estring\u003c/span\u003e\n\u003c/td\u003e\n\u003ctd class=\"description last\"\u003e\u003cp\u003ea map containing symbols information, if not given it will be read from /tmp/perf-\u003cpid\u003e.map.\u003c/pid\u003e\u003c/p\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"name\"\u003e\u003ccode\u003etype\u003c/code\u003e\u003c/td\u003e\n\u003ctd class=\"type\"\u003e\n\u003cspan class=\"param-type\"\u003estring\u003c/span\u003e\n\u003c/td\u003e\n\u003ctd class=\"description last\"\u003e\u003cp\u003etype of input \u003ccode\u003eperf|dtrace\u003c/code\u003e. If not supplied it will be detected.\u003c/p\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"name\"\u003e\u003ccode\u003eshortStack\u003c/code\u003e\u003c/td\u003e\n\u003ctd class=\"type\"\u003e\n\u003cspan class=\"param-type\"\u003eBoolean\u003c/span\u003e\n\u003c/td\u003e\n\u003ctd class=\"description last\"\u003e\u003cp\u003estacks that have only one line are ignored unless this flag is set\u003c/p\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"name\"\u003e\u003ccode\u003eoptimizationinfo\u003c/code\u003e\u003c/td\u003e\n\u003ctd class=\"type\"\u003e\n\u003cspan class=\"param-type\"\u003eBoolean\u003c/span\u003e\n\u003c/td\u003e\n\u003ctd class=\"description last\"\u003e\u003cp\u003eJS optimization info is removed unless this flag is set (default: false)\u003c/p\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"name\"\u003e\u003ccode\u003eunresolveds\u003c/code\u003e\u003c/td\u003e\n\u003ctd class=\"type\"\u003e\n\u003cspan class=\"param-type\"\u003eBoolean\u003c/span\u003e\n\u003c/td\u003e\n\u003ctd class=\"description last\"\u003e\u003cp\u003eunresolved addresses like \u003ccode\u003e0x1a23c\u003c/code\u003e are filtered from the trace unless this flag is set (default: false)\u003c/p\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"name\"\u003e\u003ccode\u003esysinternals\u003c/code\u003e\u003c/td\u003e\n\u003ctd class=\"type\"\u003e\n\u003cspan class=\"param-type\"\u003eBoolean\u003c/span\u003e\n\u003c/td\u003e\n\u003ctd class=\"description last\"\u003e\u003cp\u003esysinternals like \u003ccode\u003e__lib_c_start...\u003c/code\u003e are filtered from the trace unless this flag is set (default: false)\u003c/p\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"name\"\u003e\u003ccode\u003ev8internals\u003c/code\u003e\u003c/td\u003e\n\u003ctd class=\"type\"\u003e\n\u003cspan class=\"param-type\"\u003eBoolean\u003c/span\u003e\n\u003c/td\u003e\n\u003ctd class=\"description last\"\u003e\u003cp\u003ev8internals like \u003ccode\u003ev8::internal::...\u003c/code\u003e are filtered from the trace unless this flag is set (default: false)\u003c/p\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"name\"\u003e\u003ccode\u003ev8gc\u003c/code\u003e\u003c/td\u003e\n\u003ctd class=\"type\"\u003e\n\u003cspan class=\"param-type\"\u003eBoolean\u003c/span\u003e\n\u003c/td\u003e\n\u003ctd class=\"description last\"\u003e\u003cp\u003ewhen v8internals are filtered, garbage collection info is as well unless this flag set  (default: true)\u003c/p\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cdl class=\"details\"\u003e\n\u003cdt class=\"tag-source\"\u003eSource:\u003c/dt\u003e\n\u003cdd class=\"tag-source\"\u003e\u003cul class=\"dummy\"\u003e\n\u003cli\u003e\n\u003ca href=\"https://github.com/thlorenz/cpuprofilify/blob/master/index.js\"\u003eindex.js\u003c/a\u003e\n\u003cspan\u003e, \u003c/span\u003e\n\u003ca href=\"https://github.com/thlorenz/cpuprofilify/blob/master/index.js#L30\"\u003elineno 30\u003c/a\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\u003c/dd\u003e\n\u003c/dl\u003e\n\u003ch5\u003eReturns:\u003c/h5\u003e\n\u003cdiv class=\"param-desc\"\u003e\n\u003cp\u003ean cpuprofile presentation of the given trace\u003c/p\u003e\n\u003c/div\u003e\n\u003cdl\u003e\n\u003cdt\u003e\nType\n\u003c/dt\u003e\n\u003cdd\u003e\n\u003cspan class=\"param-type\"\u003eObject\u003c/span\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/article\u003e\n\u003c/section\u003e\n\u003c/div\u003e\n\n*generated with [docme](https://github.com/thlorenz/docme)*\n\u003c/div\u003e\n\u003c!-- END docme generated API please keep comment here to allow auto update --\u003e\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthlorenz%2Fcpuprofilify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthlorenz%2Fcpuprofilify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthlorenz%2Fcpuprofilify/lists"}