{"id":22861537,"url":"https://github.com/discoveryjs/cpupro","last_synced_at":"2025-05-16T03:06:29.966Z","repository":{"id":66091709,"uuid":"456425492","full_name":"discoveryjs/cpupro","owner":"discoveryjs","description":"Rethinking of CPU profile analysis","archived":false,"fork":false,"pushed_at":"2025-05-08T05:20:19.000Z","size":15426,"stargazers_count":636,"open_issues_count":6,"forks_count":12,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-10T07:30:46.706Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://discoveryjs.github.io/cpupro/","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/discoveryjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-02-07T08:52:14.000Z","updated_at":"2025-05-09T20:42:38.000Z","dependencies_parsed_at":"2023-11-16T17:30:30.960Z","dependency_job_id":"2a4b4485-fd81-4549-9a48-5c377fcf2320","html_url":"https://github.com/discoveryjs/cpupro","commit_stats":{"total_commits":413,"total_committers":2,"mean_commits":206.5,"dds":0.002421307506053294,"last_synced_commit":"fa1784e47876fa9124c8f95581409f7c384e8ed0"},"previous_names":["discoveryjs/cpupro"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discoveryjs%2Fcpupro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discoveryjs%2Fcpupro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discoveryjs%2Fcpupro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discoveryjs%2Fcpupro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/discoveryjs","download_url":"https://codeload.github.com/discoveryjs/cpupro/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254190388,"owners_count":22029639,"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-12-13T10:01:49.629Z","updated_at":"2025-05-16T03:06:24.952Z","avatar_url":"https://github.com/discoveryjs.png","language":"JavaScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"[![NPM version](https://img.shields.io/npm/v/cpupro.svg)](https://www.npmjs.com/package/cpupro)\n\n# CPUpro\n\nRethinking of CPU profile analysis and processing. Focused on profiles and logs of any size collected in V8 runtimes: Node.js, Deno and Chromium browsers.\n\nSupported formats:\n\n* [V8 CPU profile](https://nodejs.org/docs/latest/api/cli.html#--cpu-prof) (.cpuprofile)\n* [V8 log](https://v8.dev/docs/profile) preprocessed with [--preprocess](https://v8.dev/docs/profile#web-ui-for---prof) (.json)\n* [Chromium Performance Profile](https://developer.chrome.com/docs/devtools/performance/reference#save) format (.json)\n* [Edge Enhanced Performance Traces](https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/experimental-features/share-traces) (.devtools)\n\n\u003e STATUS: MVP\n\u003e\n\u003e The project is at an early stage of development. Some things have yet to be added and polished. Feel free to create an issue if you found a bug or have an idea.\n\n## Usage\n\n### Scenario #1 – A viewer for CPU profiles\n\nHead to the [viewer on GitHub pages](https://discoveryjs.github.io/cpupro/), open a file in one of supported formats or drop it on the page.\n\n\u003cimg width=\"1267\" alt=\"Demo\" src=\"https://github.com/lahmatiy/cpupro/assets/270491/ea4d54b7-8d37-456a-8db3-628a1da7df3e\"\u003e\n\n### Scenario #2 – CLI\n\nCLI allows to generate a report (an viewer with embedded data) from a profile file.\n\nTo use CLI install `cpupro` globally using `npm install -g cpupro`, or use `npx cpupro`.\n\n- open viewer without embedded data in default browser:\n  ```\n  cpupro\n  ```\n- open viewer with `test.cpuprofile` data embedded:\n  ```\n  cpupro test.cpuprofile\n  ```\n- open viewer with data embedded from `stdin`:\n  ```\n  cpupro - \u003ctest.cpuprofile\n  ```\n  ```\n  cat test.cpuprofile | cpupro -\n  ```\n- get usage information:\n  ```\n  cpupro -h\n  ```\n  ```\n  Usage:\n  \n      cpupro [filepath] [options]\n  \n  Options:\n  \n      -f, --filename \u003cfilename\u003e    Specify a filename for a report; should ends with .htm or .html,\n                                   otherwise .html will be added\n      -h, --help                   Output usage information\n      -n, --no-open                Prevent open a report in browser, the report will be written to file\n      -o, --output-dir \u003cpath\u003e      Specify an output path for a report (current working dir by default)\n      -v, --version                Output version\n  ```\n\n### Scenario #3 – A library for Node.js program\n\nMain `cpupro` API is similar to [`console.profile()`](https://developer.mozilla.org/en-US/docs/Web/API/console/profile) / [`console.profileEnd()`](https://developer.mozilla.org/en-US/docs/Web/API/console/profileEnd) with an exception that the `profileEnd()` method does nothing but returns API for saving data to a file or generating a report:\n\n```js\nconst profiler = require('cpupro');\n\nprofiler.profile('profileName');\n\n// ... do something\n\nconst profile = profiler.profileEnd('profileName');\n\n// write data to .cpuprofile file\nprofile.writeToFile('./path/to/demo.cpuprofile');\n// or write a report (the viewer with embedded data) to file\nprofile.report.writeToFile('report.html');\n// or open the report in a browser\nprofile.report.open();\n```\n\nIt is allowed to have several profiles being recorded at once. It's possible to use a reference to profile record API instead of a profile name:\n\n```js\nconst profiler = require('cpupro');\n\nconst profile = profiler.profile();\n\n// ... do something\n\n// end profiling and open a report in a browser\nprofile.profileEnd().openReport();\n```\n\nAn alternative approach is to invoke actions such as writeToFile(), writeJsonxlToFile(), writeReport(), and openReport() at the start of profiling. These actions will be executed upon calling profileEnd() or upon process exit if profileEnd() is not explicitly invoked:\n\n```js\nconst profiler = require('cpupro');\n\nprofiler.profile()\n  .writeToFile('./path/to/demo.cpuprofile');\n\n// calling profileEnd() is not necessary if a CPU profile should be dumped to a file upon process exit\n```\n\n### Scenario #4 – A preload module for Node.js scripts\n\nRecord profile, generate report and open it in a browser:\n\n```\nnode --require cpupro path/to/script.js\n```\n\nRecord profile, generate report and write into a file:\n\n```\nnode --require cpupro/file path/to/script.js\n# or\nnode --require cpupro/file/report path/to/script.js\n```\n\nRecord profile and write it into `.cpuprofile` file:\n\n```\nnode --require cpupro/file/data path/to/script.js\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscoveryjs%2Fcpupro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiscoveryjs%2Fcpupro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscoveryjs%2Fcpupro/lists"}