@jsenv/performance-impact 4.1.4 → 4.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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/performance-impact",
|
|
3
|
-
"version": "4.1
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "Report pull request impacts on performance metrics",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -35,9 +35,10 @@
|
|
|
35
35
|
"test": "node ./scripts/test.mjs"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@jsenv/dynamic-import-worker": "1.1
|
|
39
|
-
"@jsenv/filesystem": "4.
|
|
40
|
-
"@jsenv/github-pull-request-impact": "1.7.
|
|
41
|
-
"@jsenv/
|
|
38
|
+
"@jsenv/dynamic-import-worker": "1.2.1",
|
|
39
|
+
"@jsenv/filesystem": "4.6.6",
|
|
40
|
+
"@jsenv/github-pull-request-impact": "1.7.5",
|
|
41
|
+
"@jsenv/humanize": "1.1.0",
|
|
42
|
+
"@jsenv/log": "3.5.2"
|
|
42
43
|
}
|
|
43
44
|
}
|
package/readme.md
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
|
|
9
9
|
Disclaimer: This tool should not be used to catch small performance variations because they are hard to distinguish from the natural variations of performance metrics (see [performance variability](#Performance-variability)).
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Pull request comment
|
|
12
12
|
|
|
13
13
|
_Screenshot of a pull request comment_
|
|
14
14
|
|
|
15
15
|

|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
## Performance variability
|
|
18
18
|
|
|
19
19
|
Performance metrics will change due to inherent variability, **even if there hasn't been a code change**.
|
|
20
20
|
It can be mitigated by measuring performance multiple times.
|
|
@@ -22,18 +22,18 @@ But you should always keep in mind this variability before drawing conclusions a
|
|
|
22
22
|
|
|
23
23
|
With time you'll be capable to recognize unusual variation in your performance metrics.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
## How to catch small performance impacts?
|
|
26
26
|
|
|
27
|
-
Catching
|
|
27
|
+
Catching (very) small performance impacts with confidence requires repetition and time. You need to:
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
1. Let your code be used a lot of times in a lot of scenarios and see the results. This could be scripts, real users or both.
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
2. And or push your performance metrics in a tool like Kibana or DataDog and check the tendency of your performance metrics.
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
In any case it means you have to wait before knowing the real performance impact.
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
## Recommended approach to catch performance impacts
|
|
36
36
|
|
|
37
37
|
1. measure some performance metrics
|
|
38
|
-
2.
|
|
38
|
+
2. Big variations can be anticipated and catched by `@jsenv/performance-impact`
|
|
39
39
|
3. For small variations, upload performance metrics to a dashboard. Then, periodically watch the dashboard to check performance metrics tendency over time
|
|
@@ -24,13 +24,15 @@ export const importMetricFromFiles = async ({
|
|
|
24
24
|
const metricsDescription = metricsDescriptions[metricName];
|
|
25
25
|
const {
|
|
26
26
|
file,
|
|
27
|
+
env,
|
|
28
|
+
params,
|
|
27
29
|
iterations,
|
|
28
30
|
msToWaitBetweenEachIteration = 100,
|
|
29
31
|
} = metricsDescription;
|
|
30
32
|
const url = new URL(file, directoryUrl).href;
|
|
31
33
|
|
|
32
34
|
const measure = async () => {
|
|
33
|
-
const metrics = await importOneExportFromFile(url);
|
|
35
|
+
const metrics = await importOneExportFromFile(url, { env, params });
|
|
34
36
|
assertMetrics(metrics, `in ${file}`);
|
|
35
37
|
return metrics;
|
|
36
38
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { humanizeFileSize, humanizeDuration } from "@jsenv/humanize";
|
|
2
2
|
|
|
3
3
|
export const formatMetricValue = ({ value, unit }) => {
|
|
4
4
|
return formatters[unit](value);
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
const formatters = {
|
|
8
|
-
ms:
|
|
9
|
-
byte:
|
|
8
|
+
ms: humanizeDuration,
|
|
9
|
+
byte: humanizeFileSize,
|
|
10
10
|
undefined: (value) => value,
|
|
11
11
|
};
|