@jsenv/performance-impact 2.1.0 → 2.2.1
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,7 +1,7 @@
|
|
|
1
1
|
import { assertAndNormalizeDirectoryUrl, resolveUrl } from "@jsenv/filesystem"
|
|
2
2
|
import { createLogger } from "@jsenv/logger"
|
|
3
|
+
import { importOneExportFromFile } from "@jsenv/dynamic-import-worker"
|
|
3
4
|
|
|
4
|
-
import { collectOneExportFromFile } from "./internal/collectOneExportFromFile.js"
|
|
5
5
|
import { measureMultipleTimes } from "./internal/measureMultipleTimes.js"
|
|
6
6
|
import { assertMetrics } from "./internal/assertions.js"
|
|
7
7
|
import { computeMetricsMedian } from "./internal/computeMetricsMedian.js"
|
|
@@ -21,7 +21,7 @@ export const importMetricFromFiles = async ({ logLevel, directoryUrl, metricsDes
|
|
|
21
21
|
const url = resolveUrl(file, directoryUrl)
|
|
22
22
|
|
|
23
23
|
const measure = async () => {
|
|
24
|
-
const metrics = await
|
|
24
|
+
const metrics = await importOneExportFromFile(url)
|
|
25
25
|
assertMetrics(metrics, `in ${file}`)
|
|
26
26
|
return metrics
|
|
27
27
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { formatRatioAsPercentage } from "../formatRatio.js"
|
|
2
|
-
import { median } from "../median.js"
|
|
3
2
|
|
|
4
3
|
export const jsenvFormatGroupSummary = ({ groupName, beforeMergeMetrics, afterMergeMetrics }) => {
|
|
5
4
|
if (!beforeMergeMetrics) {
|
|
@@ -7,7 +6,8 @@ export const jsenvFormatGroupSummary = ({ groupName, beforeMergeMetrics, afterMe
|
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
const allRatios = getAllImpactRatios({ beforeMergeMetrics, afterMergeMetrics })
|
|
10
|
-
|
|
9
|
+
const ratiosCount = allRatios.length
|
|
10
|
+
if (ratiosCount === 0) {
|
|
11
11
|
return `${groupName} (no impact)`
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -16,8 +16,7 @@ export const jsenvFormatGroupSummary = ({ groupName, beforeMergeMetrics, afterMe
|
|
|
16
16
|
return `${groupName} (no impact)`
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
return `${groupName} (${formatRatioAsPercentage(medianRatio)})`
|
|
19
|
+
return `${groupName} (${formatRatioAsPercentage(ratioSum / ratiosCount)})`
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
const getAllImpactRatios = ({ afterMergeMetrics, beforeMergeMetrics }) => {
|
|
@@ -32,6 +31,12 @@ const getAllImpactRatios = ({ afterMergeMetrics, beforeMergeMetrics }) => {
|
|
|
32
31
|
const metricValueBeforeMerge = metricBeforeMerge.value
|
|
33
32
|
const metricValueAfterMerge = metricAfterMerge.value
|
|
34
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
|
+
|
|
35
40
|
const metricDiffRatio =
|
|
36
41
|
metricDiff === 0
|
|
37
42
|
? 0
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolveUrl, assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem"
|
|
2
2
|
import { commentGitHubPullRequestImpact } from "@jsenv/github-pull-request-impact"
|
|
3
|
+
import { importOneExportFromFile } from "@jsenv/dynamic-import-worker"
|
|
3
4
|
|
|
4
|
-
import { collectOneExportFromFile } from "./internal/collectOneExportFromFile.js"
|
|
5
5
|
import { assertPerformanceReport } from "./internal/assertions.js"
|
|
6
6
|
import { createPerfImpactComment } from "./internal/comment/createPerfImpactComment.js"
|
|
7
7
|
import { jsenvCommentParameters } from "./internal/comment/jsenvCommentParameters.js"
|
|
@@ -50,7 +50,7 @@ export const reportPerformanceImpact = async ({
|
|
|
50
50
|
|
|
51
51
|
collectInfo: async ({ execCommandInProjectDirectory }) => {
|
|
52
52
|
await execCommandInProjectDirectory(installCommand)
|
|
53
|
-
const performanceReport = await
|
|
53
|
+
const performanceReport = await importOneExportFromFile(performanceReportUrl)
|
|
54
54
|
assertPerformanceReport(performanceReport)
|
|
55
55
|
return { version: 1, data: performanceReport }
|
|
56
56
|
},
|