@jsenv/performance-impact 2.2.1 → 2.2.2
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/package.json +22 -31
- package/readme.md +1 -1
- package/src/importMetricFromFiles.js +38 -23
- package/src/internal/formatByte.js +1 -1
- package/src/internal/formatMs.js +1 -1
- package/src/reportPerformanceImpact.js +7 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/performance-impact",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "Report pull request impacts on performance metrics",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -10,13 +10,15 @@
|
|
|
10
10
|
},
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/jsenv/
|
|
13
|
+
"url": "https://github.com/jsenv/workflow",
|
|
14
|
+
"directory": "packages/jsenv-performance-impact"
|
|
14
15
|
},
|
|
15
16
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
17
|
+
"node": ">=16.13.0"
|
|
17
18
|
},
|
|
18
19
|
"publishConfig": {
|
|
19
|
-
"access": "public"
|
|
20
|
+
"access": "public",
|
|
21
|
+
"registry": "https://registry.npmjs.org"
|
|
20
22
|
},
|
|
21
23
|
"type": "module",
|
|
22
24
|
"exports": {
|
|
@@ -25,45 +27,34 @@
|
|
|
25
27
|
},
|
|
26
28
|
"./*": "./*"
|
|
27
29
|
},
|
|
30
|
+
"main": "./main.js",
|
|
28
31
|
"files": [
|
|
29
32
|
"/src/",
|
|
30
33
|
"/main.js"
|
|
31
34
|
],
|
|
32
35
|
"scripts": {
|
|
33
|
-
"eslint
|
|
34
|
-
"
|
|
35
|
-
"measure-performances": "node --expose-gc ./script/performance/generate_performance_report.mjs --log",
|
|
36
|
-
"generate-comment-snapshot-file": "node ./test/comment_snapshot/generate_comment_snapshot_file.mjs",
|
|
36
|
+
"eslint": "npx eslint . --ext=.js,.mjs",
|
|
37
|
+
"importmap": "node ./script/importmap/importmap.mjs",
|
|
37
38
|
"test": "node ./script/test/test.mjs",
|
|
38
39
|
"test-with-coverage": "npm run test -- --coverage",
|
|
39
|
-
"prettier
|
|
40
|
-
"prettier-format-stage": "npm run prettier-format -- --staged",
|
|
41
|
-
"prettier-check": "npm run prettier-format -- --dry-run",
|
|
42
|
-
"prepublishOnly": "node ./script/publish/remove_postinstall.mjs",
|
|
43
|
-
"postpublish": "node ./script/publish/restore_postinstall.mjs"
|
|
40
|
+
"prettier": "prettier --write ."
|
|
44
41
|
},
|
|
45
42
|
"dependencies": {
|
|
46
43
|
"@jsenv/dynamic-import-worker": "1.0.0",
|
|
47
|
-
"@jsenv/filesystem": "2.
|
|
48
|
-
"@jsenv/github-pull-request-impact": "1.6.
|
|
44
|
+
"@jsenv/filesystem": "2.7.1",
|
|
45
|
+
"@jsenv/github-pull-request-impact": "1.6.6",
|
|
49
46
|
"@jsenv/logger": "4.0.1",
|
|
50
|
-
"bytes": "3.1.
|
|
51
|
-
"humanize-duration": "3.27.
|
|
47
|
+
"bytes": "3.1.1",
|
|
48
|
+
"humanize-duration": "3.27.1"
|
|
52
49
|
},
|
|
53
50
|
"devDependencies": {
|
|
54
|
-
"@
|
|
55
|
-
"@
|
|
56
|
-
"@jsenv/
|
|
57
|
-
"@jsenv/
|
|
58
|
-
"@jsenv/
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"@jsenv/importmap-node-module": "2.3.1",
|
|
63
|
-
"@jsenv/package-publish": "1.6.2",
|
|
64
|
-
"@jsenv/prettier-check-project": "5.6.1",
|
|
65
|
-
"eslint": "7.32.0",
|
|
66
|
-
"eslint-plugin-import": "2.25.2",
|
|
67
|
-
"prettier": "2.4.1"
|
|
51
|
+
"@jsenv/assert": "2.4.1",
|
|
52
|
+
"@jsenv/core": "25.3.0",
|
|
53
|
+
"@jsenv/eslint-config": "16.0.9",
|
|
54
|
+
"@jsenv/importmap-eslint-resolver": "5.2.5",
|
|
55
|
+
"@jsenv/importmap-node-module": "5.1.3",
|
|
56
|
+
"eslint": "8.7.0",
|
|
57
|
+
"eslint-plugin-import": "2.25.4",
|
|
58
|
+
"prettier": "2.5.1"
|
|
68
59
|
}
|
|
69
60
|
}
|
package/readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Performance impact [](https://www.npmjs.com/package/@jsenv/performance-impact)
|
|
1
|
+
# Performance impact [](https://www.npmjs.com/package/@jsenv/performance-impact)
|
|
2
2
|
|
|
3
3
|
`@jsenv/performance-impact` analyses a pull request impact on your performance metrics. This analysis is posted in a comment of the pull request on GitHub.
|
|
4
4
|
|
|
@@ -7,34 +7,49 @@ import { assertMetrics } from "./internal/assertions.js"
|
|
|
7
7
|
import { computeMetricsMedian } from "./internal/computeMetricsMedian.js"
|
|
8
8
|
import { formatMetricsLog } from "./internal/formatMetricsLog.js"
|
|
9
9
|
|
|
10
|
-
export const importMetricFromFiles = async ({
|
|
10
|
+
export const importMetricFromFiles = async ({
|
|
11
|
+
logLevel,
|
|
12
|
+
directoryUrl,
|
|
13
|
+
metricsDescriptions,
|
|
14
|
+
}) => {
|
|
11
15
|
const logger = createLogger({ logLevel })
|
|
12
16
|
|
|
13
17
|
directoryUrl = assertAndNormalizeDirectoryUrl(directoryUrl)
|
|
14
18
|
|
|
15
19
|
const allMetrics = {}
|
|
16
|
-
await Object.keys(metricsDescriptions).reduce(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
20
|
+
await Object.keys(metricsDescriptions).reduce(
|
|
21
|
+
async (previous, metricName) => {
|
|
22
|
+
await previous
|
|
23
|
+
|
|
24
|
+
const metricsDescription = metricsDescriptions[metricName]
|
|
25
|
+
const {
|
|
26
|
+
file,
|
|
27
|
+
iterations,
|
|
28
|
+
msToWaitBetweenEachIteration = 100,
|
|
29
|
+
} = metricsDescription
|
|
30
|
+
const url = resolveUrl(file, directoryUrl)
|
|
31
|
+
|
|
32
|
+
const measure = async () => {
|
|
33
|
+
const metrics = await importOneExportFromFile(url)
|
|
34
|
+
assertMetrics(metrics, `in ${file}`)
|
|
35
|
+
return metrics
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const metricsWithIterations = await measureMultipleTimes(
|
|
39
|
+
measure,
|
|
40
|
+
iterations,
|
|
41
|
+
{
|
|
42
|
+
msToWaitBetweenEachIteration,
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
const metrics = computeMetricsMedian(metricsWithIterations)
|
|
46
|
+
|
|
47
|
+
logger.info(formatMetricsLog(metrics))
|
|
48
|
+
|
|
49
|
+
allMetrics[metricName] = metrics
|
|
50
|
+
},
|
|
51
|
+
Promise.resolve(),
|
|
52
|
+
)
|
|
38
53
|
|
|
39
54
|
return allMetrics
|
|
40
55
|
}
|
package/src/internal/formatMs.js
CHANGED
|
@@ -9,7 +9,6 @@ import { jsenvCommentParameters } from "./internal/comment/jsenvCommentParameter
|
|
|
9
9
|
export const reportPerformanceImpact = async ({
|
|
10
10
|
logLevel,
|
|
11
11
|
commandLogs,
|
|
12
|
-
cancellationToken,
|
|
13
12
|
cancelOnSIGINT,
|
|
14
13
|
projectDirectoryUrl,
|
|
15
14
|
|
|
@@ -34,12 +33,14 @@ export const reportPerformanceImpact = async ({
|
|
|
34
33
|
)
|
|
35
34
|
}
|
|
36
35
|
projectDirectoryUrl = assertAndNormalizeDirectoryUrl(projectDirectoryUrl)
|
|
37
|
-
const performanceReportUrl = resolveUrl(
|
|
36
|
+
const performanceReportUrl = resolveUrl(
|
|
37
|
+
performanceReportPath,
|
|
38
|
+
projectDirectoryUrl,
|
|
39
|
+
)
|
|
38
40
|
|
|
39
41
|
return commentGitHubPullRequestImpact({
|
|
40
42
|
logLevel,
|
|
41
43
|
commandLogs,
|
|
42
|
-
cancellationToken,
|
|
43
44
|
cancelOnSIGINT,
|
|
44
45
|
projectDirectoryUrl,
|
|
45
46
|
|
|
@@ -50,7 +51,9 @@ export const reportPerformanceImpact = async ({
|
|
|
50
51
|
|
|
51
52
|
collectInfo: async ({ execCommandInProjectDirectory }) => {
|
|
52
53
|
await execCommandInProjectDirectory(installCommand)
|
|
53
|
-
const performanceReport = await importOneExportFromFile(
|
|
54
|
+
const performanceReport = await importOneExportFromFile(
|
|
55
|
+
performanceReportUrl,
|
|
56
|
+
)
|
|
54
57
|
assertPerformanceReport(performanceReport)
|
|
55
58
|
return { version: 1, data: performanceReport }
|
|
56
59
|
},
|