@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.4",
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.0",
39
- "@jsenv/filesystem": "4.3.2",
40
- "@jsenv/github-pull-request-impact": "1.7.4",
41
- "@jsenv/log": "3.4.2"
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
- # Pull request comment
11
+ ## Pull request comment
12
12
 
13
13
  _Screenshot of a pull request comment_
14
14
 
15
15
  ![stuff](./docs/pull_request_comment.png)
16
16
 
17
- # Performance variability
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
- # How to catch small performance impacts?
25
+ ## How to catch small performance impacts?
26
26
 
27
- Catching small to very small performance impacts with confidence requires a LOT of repetition and time. Both strategies means you will have to wait before knowing the real performance impact.
27
+ Catching (very) small performance impacts with confidence requires repetition and time. You need to:
28
28
 
29
- _How to catch small impacts with a lot of repetition?_
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
- - 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.
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
- - Push your performance metrics in a tool like Kibana or DataDog and check the tendency of your performance metrics.
33
+ In any case it means you have to wait before knowing the real performance impact.
34
34
 
35
- In the end I would recommend the following approach:
35
+ ## Recommended approach to catch performance impacts
36
36
 
37
37
  1. measure some performance metrics
38
- 2. Use `@jsenv/performance-impact` to anticipate big variations
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 { byteAsFileSize, msAsDuration } from "@jsenv/log";
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: msAsDuration,
9
- byte: byteAsFileSize,
8
+ ms: humanizeDuration,
9
+ byte: humanizeFileSize,
10
10
  undefined: (value) => value,
11
11
  };
@@ -1,4 +1,4 @@
1
- import { setRoundedPrecision } from "@jsenv/log";
1
+ import { setRoundedPrecision } from "@jsenv/humanize/src/utils/decimals.js";
2
2
 
3
3
  export const formatRatioAsPercentage = (ratio) => {
4
4
  const percentage = ratio * 100;