8000 [cpu-profile-summarizer] Add new CLI tool for summarizing many V8 CPU… · Hashah1/rushstack@f352d59 · GitHub
[go: up one dir, main page]

Skip to content

Commit f352d59

Browse files
authored
[cpu-profile-summarizer] Add new CLI tool for summarizing many V8 CPU Profiles (microsoft#5098)
* [cpu-profile-summarizer] Implement * Switch to ts-command-line --------- Co-authored-by: David Michon <dmichon-msft@users.noreply.github.com>
1 parent faad805 commit f352d59

File tree

17 files changed

+722
-0
lines changed

17 files changed

+722
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ These GitHub repositories provide supplementary resources for Rush Stack:
5050
| ------ | ------- | --------- | ------- |
5151
| [/apps/api-documenter](./apps/api-documenter/) | [![npm version](https://badge.fury.io/js/%40microsoft%2Fapi-documenter.svg)](https://badge.fury.io/js/%40microsoft%2Fapi-documenter) | [changelog](./apps/api-documenter/CHANGELOG.md) | [@microsoft/api-documenter](https://www.npmjs.com/package/@microsoft/api-documenter) |
5252
| [/apps/api-extractor](./apps/api-extractor/) | [![npm version](https://badge.fury.io/js/%40microsoft%2Fapi-extractor.svg)](https://badge.fury.io/js/%40microsoft%2Fapi-extractor) | [changelog](./apps/api-extractor/CHANGELOG.md) | [@microsoft/api-extractor](https://www.npmjs.com/package/@microsoft/api-extractor) |
53+
| [/apps/cpu-profile-summarizer](./apps/cpu-profile-summarizer/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fcpu-profile-summarizer.svg)](https://badge.fury.io/js/%40rushstack%2Fcpu-profile-summarizer) | [changelog](./apps/cpu-profile-summarizer/CHANGELOG.md) | [@rushstack/cpu-profile-summarizer](https://www.npmjs.com/package/@rushstack/cpu-profile-summarizer) |
5354
| [/apps/heft](./apps/heft/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fheft.svg)](https://badge.fury.io/js/%40rushstack%2Fheft) | [changelog](./apps/heft/CHANGELOG.md) | [@rushstack/heft](https://www.npmjs.com/package/@rushstack/heft) |
5455
| [/apps/lockfile-explorer](./apps/lockfile-explorer/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Flockfile-explorer.svg)](https://badge.fury.io/js/%40rushstack%2Flockfile-explorer) | [changelog](./apps/lockfile-explorer/CHANGELOG.md) | [@rushstack/lockfile-explorer](https://www.npmjs.com/package/@rushstack/lockfile-explorer) |
5556
| [/apps/rundown](./apps/rundown/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frundown.svg)](https://badge.fury.io/js/%40rushstack%2Frundown) | [changelog](./apps/rundown/CHANGELOG.md) | [@rushstack/rundown](https://www.npmjs.com/package/@rushstack/rundown) |
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// This is a workaround for https://github.com/eslint/eslint/issues/3458
2+
require('local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution');
3+
// This is a workaround for https://github.com/microsoft/rushstack/issues/3021
4+
require('local-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names');
5+
6+
module.exports = {
7+
extends: [
8+
'local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool',
9+
'local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals'
10+
],
11+
parserOptions: { tsconfigRootDir: __dirname },
12+
13+
overrides: [
14+
{
15+
files: ['*.ts', '*.tsx'],
16+
rules: {
17+
'no-console': 'off'
18+
}
19+
}
20+
]
21+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# THIS IS A STANDARD TEMPLATE FOR .npmignore FILES IN THIS REPO.
2+
3+
# Ignore all files by default, to avoid accidentally publishing unintended files.
4+
*
5+
6+
# Use negative patterns to bring back the specific things we want to publish.
7+
!/bin/**
8+
!/lib/**
9+
!/lib-*/**
10+
!/dist/**
11+
12+
!CHANGELOG.md
13+
!CHANGELOG.json
14+
!heft-plugin.json
15+
!rush-plugin-manifest.json
16+
!ThirdPartyNotice.txt
17+
18+
# Ignore certain patterns that should not get published.
19+
/dist/*.stats.*
20+
/lib/**/test/
21+
/lib-*/**/test/
22+
*.test.js
23+
24+
# NOTE: These don't need to be specified, because NPM includes them automatically.
25+
#
26+
# package.json
27+
# README.md
28+
# LICENSE
29+
30+
# ---------------------------------------------------------------------------
31+
# DO NOT MODIFY ABOVE THIS LINE! Add any project-specific overrides below.
32+
# ---------------------------------------------------------------------------

apps/cpu-profile-summarizer/LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@rushstack/cpu-profile-summarizer
2+
3+
Copyright (c) Microsoft Corporation. All rights reserved.
4+
5+
MIT License
6+
7+
Permission is hereby granted, free of charge, to any person obtaining
8+
a copy of this software and associated documentation files (the
9+
"Software"), to deal in the Software without restriction, including
10+
without limitation the rights to use, copy, modify, merge, publish,
11+
distribute, sublicense, and/or sell copies of the Software, and to
12+
permit persons to whom the Software is furnished to do so, subject to
13+
the following conditions:
14+
15+
The above copyright notice and this permission notice shall be
16+
included in all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

apps/cpu-profile-summarizer/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# @rushstack/cpu-profile-summarizer
2+
3+
> 🚨 _EARLY PREVIEW RELEASE_ 🚨
4+
>
5+
> Not all features are implemented yet. To provide suggestions, please
6+
> [create a GitHub issue](https://github.com/microsoft/rushstack/issues/new/choose).
7+
> If you have questions, see the [Rush Stack Help page](https://rushstack.io/pages/help/support/)
8+
> for support resources.
9+
10+
The `cpu-profile-summarizer` command line tool helps you:
11+
12+
- Collate self/total CPU usage statistics for an entire monorepo worth of V8 .cpuprofile files
13+
14+
## Usage
15+
16+
It's recommended to install this package globally:
17+
18+
```
19+
# Install the NPM package
20+
npm install -g @rushstack/cpu-profile-summarizer
21+
22+
# Process a folder of cpuprofile files into a summary tsv file
23+
cpu-profile-summarizer --input FOLDER --output FILE.tsv
24+
```
25+
26+
The output file is in the tab-separated values (tsv) format.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
require('../lib/start.js');
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "local-node-rig/profiles/default/config/jest.config.json"
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
// The "rig.json" file directs tools to look for their config files in an external package.
3+
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
4+
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
5+
6+
"rigPackageName": "local-node-rig"
7+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "@rushstack/cpu-profile-summarizer",
3+
"version": "0.0.0",
4+
"description": "CLI tool for running analytics on multiple V8 .cpuprofile files",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/microsoft/rushstack.git",
8+
"directory": "apps/cpu-profile-summarizer"
9+
},
10+
"bin": {
11+
"cpu-profile-summarizer": "./bin/cpu-profile-summarizer"
12+
},
13+
"license": "MIT",
14+
"scripts": {
15+
"start": "node lib/start",
16+
"build": "heft build --clean",
17+
"_phase:build": "heft run --only build -- --clean",
18+
"_phase:test": "heft run --only test -- --clean"
19+
},
20+
"dependencies": {
21+
"@rushstack/ts-command-line": "workspace:*",
22+
"@rushstack/worker-pool": "workspace:*"
23+
},
24+
"devDependencies": {
25+
"@rushstack/heft": "workspace:*",
26+
"local-node-rig": "workspace:*",
27+
"typescript": "~5.4.2"
28+
}
29+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2+
// See LICENSE in the project root for license information.
3+
4+
import type { IProfileSummary } from './types';
5+
6+
/**
7+
* A message sent to a worker to process a file (or shutdown).
8+
*/
9+
export type IMessageToWorker = string | false;
10+
11+
/**
12+
* A message sent from a worker to the main thread on success.
13+
*/
14+
export interface IWorkerSuccessMessage {
15+
type: 'success';
16+
/**
17+
* The file requested to be processed.
18+
*/
19+
file: string;
20+
/**
21+
* The summary of the profile data.
22+
*/
23+
data: IProfileSummary;
24+
}
25+
26+
/**
27+
* A message sent from a worker to the main thread on error.
28+
*/
29+
export interface IWorkerErrorMessage {
30+
type: 'error';
31+
/**
32+
* The file requested to be processed.
33+
*/
34+
file: string;
35+
/**
36+
* The error stack trace or message.
37+
*/
38+
data: string;
39+
}
40+
41+
/**
42+
* A message sent from a worker to the main thread.
43+
*/
44+
export type IMessageFromWorker = IWorkerSuccessMessage | IWorkerErrorMessage;

0 commit comments

Comments
 (0)
0