trace-engine-cli 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +342 -2
- package/dist/bin/trace-cli.d.ts +2 -0
- package/dist/bin/trace-cli.js +19 -0
- package/dist/src/cli.d.ts +1 -0
- package/dist/src/cli.js +477 -0
- package/dist/src/engine/adapter.d.ts +13 -0
- package/dist/src/engine/adapter.js +51 -0
- package/dist/src/engine/extractors/diff.d.ts +12 -0
- package/dist/src/engine/extractors/diff.js +100 -0
- package/dist/src/engine/extractors/events.d.ts +27 -0
- package/dist/src/engine/extractors/events.js +84 -0
- package/dist/src/engine/extractors/find.d.ts +12 -0
- package/dist/src/engine/extractors/find.js +100 -0
- package/dist/src/engine/extractors/insights.d.ts +15 -0
- package/dist/src/engine/extractors/insights.js +153 -0
- package/dist/src/engine/extractors/interactions.d.ts +7 -0
- package/dist/src/engine/extractors/interactions.js +55 -0
- package/dist/src/engine/extractors/navigations.d.ts +10 -0
- package/dist/src/engine/extractors/navigations.js +82 -0
- package/dist/src/engine/extractors/network.d.ts +10 -0
- package/dist/src/engine/extractors/network.js +105 -0
- package/dist/src/engine/extractors/overview.d.ts +11 -0
- package/dist/src/engine/extractors/overview.js +232 -0
- package/dist/src/engine/extractors/profile.d.ts +12 -0
- package/dist/src/engine/extractors/profile.js +83 -0
- package/dist/src/engine/extractors/scan.d.ts +37 -0
- package/dist/src/engine/extractors/scan.js +218 -0
- package/dist/src/engine/extractors/scheduling.d.ts +10 -0
- package/dist/src/engine/extractors/scheduling.js +89 -0
- package/dist/src/engine/extractors/shifts.d.ts +11 -0
- package/dist/src/engine/extractors/shifts.js +118 -0
- package/dist/src/engine/extractors/tasks.d.ts +13 -0
- package/dist/src/engine/extractors/tasks.js +156 -0
- package/dist/src/engine/helpers.d.ts +157 -0
- package/dist/src/engine/helpers.js +95 -0
- package/dist/src/engine/loader.d.ts +34 -0
- package/dist/src/engine/loader.js +142 -0
- package/dist/src/engine/types.d.ts +452 -0
- package/dist/src/engine/types.js +14 -0
- package/dist/src/formatters/index.d.ts +6 -0
- package/dist/src/formatters/index.js +66 -0
- package/dist/src/formatters/markdown.d.ts +15 -0
- package/dist/src/formatters/markdown.js +474 -0
- package/dist/src/formatters/toon.d.ts +1 -0
- package/dist/src/formatters/toon.js +17 -0
- package/dist/src/utils/filter.d.ts +47 -0
- package/dist/src/utils/filter.js +136 -0
- package/dist/src/utils/units.d.ts +24 -0
- package/dist/src/utils/units.js +57 -0
- package/package.json +45 -4
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts microseconds to milliseconds.
|
|
3
|
+
*/
|
|
4
|
+
export declare function microToMilli(microseconds: number): number;
|
|
5
|
+
/**
|
|
6
|
+
* Converts milliseconds to microseconds.
|
|
7
|
+
*/
|
|
8
|
+
export declare function milliToMicro(milliseconds: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Rounds a number to a specific number of decimal places.
|
|
11
|
+
*/
|
|
12
|
+
export declare function round(value: number, decimals?: number): number;
|
|
13
|
+
/**
|
|
14
|
+
* Formats milliseconds as a formatted string with unit suffix.
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatMs(milliseconds: number, decimals?: number): string;
|
|
17
|
+
/**
|
|
18
|
+
* Formats a byte count into human-readable size (B, KB, MB, GB, TB).
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatBytes(bytes: number): string;
|
|
21
|
+
/**
|
|
22
|
+
* Formats a decimal score with fixed precision.
|
|
23
|
+
*/
|
|
24
|
+
export declare function formatScore(score: number, decimals?: number): string;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Copyright 2026 Google LLC
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
/**
|
|
15
|
+
* Converts microseconds to milliseconds.
|
|
16
|
+
*/
|
|
17
|
+
export function microToMilli(microseconds) {
|
|
18
|
+
return microseconds / 1000;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Converts milliseconds to microseconds.
|
|
22
|
+
*/
|
|
23
|
+
export function milliToMicro(milliseconds) {
|
|
24
|
+
return milliseconds * 1000;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Rounds a number to a specific number of decimal places.
|
|
28
|
+
*/
|
|
29
|
+
export function round(value, decimals = 2) {
|
|
30
|
+
const factor = 10 ** decimals;
|
|
31
|
+
return Math.round(value * factor) / factor;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Formats milliseconds as a formatted string with unit suffix.
|
|
35
|
+
*/
|
|
36
|
+
export function formatMs(milliseconds, decimals = 2) {
|
|
37
|
+
return `${round(milliseconds, decimals)}ms`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Formats a byte count into human-readable size (B, KB, MB, GB, TB).
|
|
41
|
+
*/
|
|
42
|
+
export function formatBytes(bytes) {
|
|
43
|
+
if (bytes === 0)
|
|
44
|
+
return '0 B';
|
|
45
|
+
const absBytes = Math.abs(bytes);
|
|
46
|
+
const k = 1024;
|
|
47
|
+
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
48
|
+
const i = Math.min(sizes.length - 1, Math.max(0, Math.floor(Math.log(absBytes) / Math.log(k))));
|
|
49
|
+
const sign = bytes < 0 ? '-' : '';
|
|
50
|
+
return `${sign}${round(absBytes / k ** i, 2)} ${sizes[i]}`;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Formats a decimal score with fixed precision.
|
|
54
|
+
*/
|
|
55
|
+
export function formatScore(score, decimals = 4) {
|
|
56
|
+
return round(score, decimals).toString();
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trace-engine-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI tool for inspecting Chromium performance traces on top of DevTools Trace Engine",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"trace-cli": "./dist/bin/trace-cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/bin",
|
|
11
|
+
"dist/src"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"clean": "node --input-type=module --eval \"import fs from 'node:fs'; fs.rmSync('dist', {recursive: true, force: true});\"",
|
|
15
|
+
"build": "npm run clean && tsc",
|
|
16
|
+
"bundle:engine": "tsx scripts/bundle-engine.ts",
|
|
17
|
+
"test": "node --test --import tsx/esm 'test/**/*.test.ts' 'test/*.test.ts'",
|
|
18
|
+
"check": "biome check .",
|
|
19
|
+
"format": "biome format --write ."
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"trace",
|
|
23
|
+
"devtools",
|
|
24
|
+
"performance",
|
|
25
|
+
"cli",
|
|
26
|
+
"toon"
|
|
27
|
+
],
|
|
28
|
+
"author": "Google LLC",
|
|
29
|
+
"license": "Apache-2.0",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/ChromeDevTools/trace-engine-cli.git"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@paulirish/trace_engine": "^0.0.65",
|
|
36
|
+
"@toon-format/toon": "^4.1.1",
|
|
37
|
+
"yargs": "^18.1.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@biomejs/biome": "^2.5.11",
|
|
41
|
+
"@types/node": "^26.4.0",
|
|
42
|
+
"@types/yargs": "^17.0.35",
|
|
43
|
+
"esbuild": "^0.28.2",
|
|
44
|
+
"tsx": "^4.23.13",
|
|
45
|
+
"typescript": "^7.0.2"
|
|
46
|
+
}
|
|
47
|
+
}
|