@jsenv/performance-impact 2.2.0 → 2.2.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/performance-impact",
3
- "version": "2.2.0",
3
+ "version": "2.2.4",
4
4
  "description": "Report pull request impacts on performance metrics",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -10,10 +10,11 @@
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "https://github.com/jsenv/performance-impact"
13
+ "url": "https://github.com/jsenv/workflow",
14
+ "directory": "packages/jsenv-performance-impact"
14
15
  },
15
16
  "engines": {
16
- "node": ">=14.17.0"
17
+ "node": ">=16.13.0"
17
18
  },
18
19
  "publishConfig": {
19
20
  "access": "public",
@@ -26,45 +27,34 @@
26
27
  },
27
28
  "./*": "./*"
28
29
  },
30
+ "main": "./main.js",
29
31
  "files": [
30
32
  "/src/",
31
33
  "/main.js"
32
34
  ],
33
35
  "scripts": {
34
- "eslint-check": "node ./node_modules/eslint/bin/eslint.js . --ext=.js,.mjs",
35
- "generate-importmap": "node ./script/importmap/generate_importmap.mjs",
36
- "measure-performances": "node --expose-gc ./script/performance/generate_performance_report.mjs --log",
37
- "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",
38
38
  "test": "node ./script/test/test.mjs",
39
39
  "test-with-coverage": "npm run test -- --coverage",
40
- "prettier-format": "node ./script/prettier/prettier_format.mjs",
41
- "prettier-format-stage": "npm run prettier-format -- --staged",
42
- "prettier-check": "npm run prettier-format -- --dry-run",
43
- "prepublishOnly": "node ./script/publish/remove_postinstall.mjs",
44
- "postpublish": "node ./script/publish/restore_postinstall.mjs"
40
+ "prettier": "prettier --write ."
45
41
  },
46
42
  "dependencies": {
47
- "@jsenv/dynamic-import-worker": "1.0.0",
48
- "@jsenv/filesystem": "2.3.1",
49
- "@jsenv/github-pull-request-impact": "1.6.4",
43
+ "@jsenv/dynamic-import-worker": "1.0.1",
44
+ "@jsenv/filesystem": "2.7.1",
45
+ "@jsenv/github-pull-request-impact": "1.6.7",
50
46
  "@jsenv/logger": "4.0.1",
51
- "bytes": "3.1.0",
52
- "humanize-duration": "3.27.0"
47
+ "bytes": "3.1.1",
48
+ "humanize-duration": "3.27.1"
53
49
  },
54
50
  "devDependencies": {
55
- "@babel/core": "7.15.5",
56
- "@babel/eslint-parser": "7.15.7",
57
- "@jsenv/assert": "2.3.2",
58
- "@jsenv/codecov-upload": "3.5.0",
59
- "@jsenv/core": "23.0.5",
60
- "@jsenv/eslint-config": "16.0.8",
61
- "@jsenv/github-release-package": "1.2.3",
62
- "@jsenv/importmap-eslint-resolver": "5.1.2",
63
- "@jsenv/importmap-node-module": "2.3.1",
64
- "@jsenv/package-publish": "1.6.2",
65
- "@jsenv/prettier-check-project": "5.6.1",
66
- "eslint": "7.32.0",
67
- "eslint-plugin-import": "2.25.2",
68
- "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"
69
59
  }
70
60
  }
package/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- # Performance impact [![npm package](https://img.shields.io/npm/v/@jsenv/performance-impact.svg?logo=npm&label=package)](https://www.npmjs.com/package/@jsenv/performance-impact) [![github main](https://github.com/jsenv/performance-impact/workflows/main/badge.svg)](https://github.com/jsenv/performance-impact/actions?workflow=main) [![codecov coverage](https://codecov.io/gh/jsenv/performance-impact/branch/main/graph/badge.svg)](https://codecov.io/gh/jsenv/performance-impact)
1
+ # Performance impact [![npm package](https://img.shields.io/npm/v/@jsenv/performance-impact.svg?logo=npm&label=package)](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 ({ logLevel, directoryUrl, metricsDescriptions }) => {
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(async (previous, metricName) => {
17
- await previous
18
-
19
- const metricsDescription = metricsDescriptions[metricName]
20
- const { file, iterations, msToWaitBetweenEachIteration = 100 } = metricsDescription
21
- const url = resolveUrl(file, directoryUrl)
22
-
23
- const measure = async () => {
24
- const metrics = await importOneExportFromFile(url)
25
- assertMetrics(metrics, `in ${file}`)
26
- return metrics
27
- }
28
-
29
- const metricsWithIterations = await measureMultipleTimes(measure, iterations, {
30
- msToWaitBetweenEachIteration,
31
- })
32
- const metrics = computeMetricsMedian(metricsWithIterations)
33
-
34
- logger.info(formatMetricsLog(metrics))
35
-
36
- allMetrics[metricName] = metrics
37
- }, Promise.resolve())
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
  }
@@ -31,6 +31,12 @@ const getAllImpactRatios = ({ afterMergeMetrics, beforeMergeMetrics }) => {
31
31
  const metricValueBeforeMerge = metricBeforeMerge.value
32
32
  const metricValueAfterMerge = metricAfterMerge.value
33
33
  const metricDiff = metricValueAfterMerge - metricValueBeforeMerge
34
+ if (metricDiff === 0 && metricValueAfterMerge === 0 && metricValueBeforeMerge === 0) {
35
+ // there is no impact on a metric that is 0
36
+ // we can ignore this metric
37
+ return
38
+ }
39
+
34
40
  const metricDiffRatio =
35
41
  metricDiff === 0
36
42
  ? 0
@@ -1,4 +1,4 @@
1
- import { createRequire } from "module"
1
+ import { createRequire } from "node:module"
2
2
 
3
3
  const require = createRequire(import.meta.url)
4
4
 
@@ -1,4 +1,4 @@
1
- import { createRequire } from "module"
1
+ import { createRequire } from "node:module"
2
2
 
3
3
  const require = createRequire(import.meta.url)
4
4
 
@@ -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(performanceReportPath, projectDirectoryUrl)
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(performanceReportUrl)
54
+ const performanceReport = await importOneExportFromFile(
55
+ performanceReportUrl,
56
+ )
54
57
  assertPerformanceReport(performanceReport)
55
58
  return { version: 1, data: performanceReport }
56
59
  },