@node-cli/perf 1.0.6 → 1.0.7

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.
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import { PerformanceObserver } from "node:perf_hooks";
3
2
  export declare class Performance {
4
3
  perfObserver: PerformanceObserver;
@@ -9,7 +9,7 @@ export class Performance {
9
9
  startMarkerName;
10
10
  measureName;
11
11
  constructor(){
12
- this.perfObserver = new PerformanceObserver(/* istanbul ignore next */ ()=>{
12
+ this.perfObserver = new PerformanceObserver(/* v8 ignore next 2 */ ()=>{
13
13
  performance.clearMeasures();
14
14
  });
15
15
  this.perfObserver.observe({
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/performance.ts"],"sourcesContent":["import { PerformanceObserver, performance } from \"node:perf_hooks\";\n\nimport { Logger } from \"@node-cli/logger\";\nimport { uniqueID } from \"@node-cli/utilities\";\n\nconst logger = new Logger({\n\tboring: process.env.NODE_ENV === \"test\",\n});\n\nexport class Performance {\n\tperfObserver: PerformanceObserver;\n\tstartMarkerName: any;\n\tmeasureName: string;\n\n\tconstructor() {\n\t\tthis.perfObserver = new PerformanceObserver(\n\t\t\t/* istanbul ignore next */ () => {\n\t\t\t\tperformance.clearMeasures();\n\t\t\t},\n\t\t);\n\t\tthis.perfObserver.observe({ type: \"measure\" });\n\t}\n\n\tstart() {\n\t\tif (this.startMarkerName) {\n\t\t\tlogger.error(\"Performance.start() can only be called once\");\n\t\t} else {\n\t\t\tthis.startMarkerName = uniqueID();\n\t\t\tperformance.mark(this.startMarkerName);\n\t\t}\n\t}\n\n\tstop() {\n\t\tif (this.startMarkerName) {\n\t\t\tconst stopMarkerName = uniqueID();\n\t\t\tthis.measureName = `internal-${this.startMarkerName}-${stopMarkerName}`;\n\n\t\t\tperformance.mark(stopMarkerName);\n\n\t\t\tperformance.measure(\n\t\t\t\tthis.measureName,\n\t\t\t\tthis.startMarkerName,\n\t\t\t\tstopMarkerName,\n\t\t\t);\n\t\t\tthis.startMarkerName = undefined;\n\t\t} else {\n\t\t\tlogger.error(\n\t\t\t\t\"Performance.stop() can only be called once after Performance.start()\",\n\t\t\t);\n\t\t}\n\t}\n\n\tstatic now() {\n\t\treturn performance?.now() * 1e6;\n\t}\n\n\tget now() {\n\t\treturn Performance.now;\n\t}\n\n\tget results() {\n\t\treturn {\n\t\t\tduration:\n\t\t\t\tperformance?.getEntriesByName(this.measureName)[0]?.duration ||\n\t\t\t\tundefined,\n\t\t};\n\t}\n}\n"],"names":["PerformanceObserver","performance","Logger","uniqueID","logger","boring","process","env","NODE_ENV","Performance","perfObserver","startMarkerName","measureName","constructor","clearMeasures","observe","type","start","error","mark","stop","stopMarkerName","measure","undefined","now","results","duration","getEntriesByName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,mBAAmB,EAAEC,WAAW,QAAQ,kBAAkB;AAEnE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,QAAQ,QAAQ,sBAAsB;AAE/C,MAAMC,SAAS,IAAIF,OAAO;IACzBG,QAAQC,QAAQC,GAAG,CAACC,QAAQ,KAAK;AAClC;AAEA,OAAO,MAAMC;IACZC,aAAkC;IAClCC,gBAAqB;IACrBC,YAAoB;IAEpBC,aAAc;QACb,IAAI,CAACH,YAAY,GAAG,IAAIV,oBACvB,wBAAwB,GAAG;YAC1BC,YAAYa,aAAa;QAC1B;QAED,IAAI,CAACJ,YAAY,CAACK,OAAO,CAAC;YAAEC,MAAM;QAAU;IAC7C;IAEAC,QAAQ;QACP,IAAI,IAAI,CAACN,eAAe,EAAE;YACzBP,OAAOc,KAAK,CAAC;QACd,OAAO;YACN,IAAI,CAACP,eAAe,GAAGR;YACvBF,YAAYkB,IAAI,CAAC,IAAI,CAACR,eAAe;QACtC;IACD;IAEAS,OAAO;QACN,IAAI,IAAI,CAACT,eAAe,EAAE;YACzB,MAAMU,iBAAiBlB;YACvB,IAAI,CAACS,WAAW,GAAG,CAAC,SAAS,EAAE,IAAI,CAACD,eAAe,CAAC,CAAC,EAAEU,eAAe,CAAC;YAEvEpB,YAAYkB,IAAI,CAACE;YAEjBpB,YAAYqB,OAAO,CAClB,IAAI,CAACV,WAAW,EAChB,IAAI,CAACD,eAAe,EACpBU;YAED,IAAI,CAACV,eAAe,GAAGY;QACxB,OAAO;YACNnB,OAAOc,KAAK,CACX;QAEF;IACD;IAEA,OAAOM,MAAM;QACZ,OAAOvB,aAAauB,QAAQ;IAC7B;IAEA,IAAIA,MAAM;QACT,OAAOf,YAAYe,GAAG;IACvB;IAEA,IAAIC,UAAU;QACb,OAAO;YACNC,UACCzB,aAAa0B,iBAAiB,IAAI,CAACf,WAAW,CAAC,CAAC,EAAE,EAAEc,YACpDH;QACF;IACD;AACD"}
1
+ {"version":3,"sources":["../src/performance.ts"],"sourcesContent":["import { PerformanceObserver, performance } from \"node:perf_hooks\";\n\nimport { Logger } from \"@node-cli/logger\";\nimport { uniqueID } from \"@node-cli/utilities\";\n\nconst logger = new Logger({\n\tboring: process.env.NODE_ENV === \"test\",\n});\n\nexport class Performance {\n\tperfObserver: PerformanceObserver;\n\tstartMarkerName: any;\n\tmeasureName: string;\n\n\tconstructor() {\n\t\tthis.perfObserver = new PerformanceObserver(\n\t\t\t/* v8 ignore next 2 */ () => {\n\t\t\t\tperformance.clearMeasures();\n\t\t\t},\n\t\t);\n\t\tthis.perfObserver.observe({ type: \"measure\" });\n\t}\n\n\tstart() {\n\t\tif (this.startMarkerName) {\n\t\t\tlogger.error(\"Performance.start() can only be called once\");\n\t\t} else {\n\t\t\tthis.startMarkerName = uniqueID();\n\t\t\tperformance.mark(this.startMarkerName);\n\t\t}\n\t}\n\n\tstop() {\n\t\tif (this.startMarkerName) {\n\t\t\tconst stopMarkerName = uniqueID();\n\t\t\tthis.measureName = `internal-${this.startMarkerName}-${stopMarkerName}`;\n\n\t\t\tperformance.mark(stopMarkerName);\n\n\t\t\tperformance.measure(\n\t\t\t\tthis.measureName,\n\t\t\t\tthis.startMarkerName,\n\t\t\t\tstopMarkerName,\n\t\t\t);\n\t\t\tthis.startMarkerName = undefined;\n\t\t} else {\n\t\t\tlogger.error(\n\t\t\t\t\"Performance.stop() can only be called once after Performance.start()\",\n\t\t\t);\n\t\t}\n\t}\n\n\tstatic now() {\n\t\treturn performance?.now() * 1e6;\n\t}\n\n\tget now() {\n\t\treturn Performance.now;\n\t}\n\n\tget results() {\n\t\treturn {\n\t\t\tduration:\n\t\t\t\tperformance?.getEntriesByName(this.measureName)[0]?.duration ||\n\t\t\t\tundefined,\n\t\t};\n\t}\n}\n"],"names":["PerformanceObserver","performance","Logger","uniqueID","logger","boring","process","env","NODE_ENV","Performance","perfObserver","startMarkerName","measureName","constructor","clearMeasures","observe","type","start","error","mark","stop","stopMarkerName","measure","undefined","now","results","duration","getEntriesByName"],"mappings":"AAAA,SAASA,mBAAmB,EAAEC,WAAW,QAAQ,kBAAkB;AAEnE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,QAAQ,QAAQ,sBAAsB;AAE/C,MAAMC,SAAS,IAAIF,OAAO;IACzBG,QAAQC,QAAQC,GAAG,CAACC,QAAQ,KAAK;AAClC;AAEA,OAAO,MAAMC;IACZC,aAAkC;IAClCC,gBAAqB;IACrBC,YAAoB;IAEpBC,aAAc;QACb,IAAI,CAACH,YAAY,GAAG,IAAIV,oBACvB,oBAAoB,GAAG;YACtBC,YAAYa,aAAa;QAC1B;QAED,IAAI,CAACJ,YAAY,CAACK,OAAO,CAAC;YAAEC,MAAM;QAAU;IAC7C;IAEAC,QAAQ;QACP,IAAI,IAAI,CAACN,eAAe,EAAE;YACzBP,OAAOc,KAAK,CAAC;QACd,OAAO;YACN,IAAI,CAACP,eAAe,GAAGR;YACvBF,YAAYkB,IAAI,CAAC,IAAI,CAACR,eAAe;QACtC;IACD;IAEAS,OAAO;QACN,IAAI,IAAI,CAACT,eAAe,EAAE;YACzB,MAAMU,iBAAiBlB;YACvB,IAAI,CAACS,WAAW,GAAG,CAAC,SAAS,EAAE,IAAI,CAACD,eAAe,CAAC,CAAC,EAAEU,gBAAgB;YAEvEpB,YAAYkB,IAAI,CAACE;YAEjBpB,YAAYqB,OAAO,CAClB,IAAI,CAACV,WAAW,EAChB,IAAI,CAACD,eAAe,EACpBU;YAED,IAAI,CAACV,eAAe,GAAGY;QACxB,OAAO;YACNnB,OAAOc,KAAK,CACX;QAEF;IACD;IAEA,OAAOM,MAAM;QACZ,OAAOvB,aAAauB,QAAQ;IAC7B;IAEA,IAAIA,MAAM;QACT,OAAOf,YAAYe,GAAG;IACvB;IAEA,IAAIC,UAAU;QACb,OAAO;YACNC,UACCzB,aAAa0B,iBAAiB,IAAI,CAACf,WAAW,CAAC,CAAC,EAAE,EAAEc,YACpDH;QACF;IACD;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-cli/perf",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "description": "Set of performance tools for Node.js",
@@ -12,8 +12,8 @@
12
12
  ],
13
13
  "node": ">=16",
14
14
  "dependencies": {
15
- "@node-cli/logger": "1.2.5",
16
- "@node-cli/utilities": "1.0.2"
15
+ "@node-cli/logger": "1.3.1",
16
+ "@node-cli/utilities": "1.0.3"
17
17
  },
18
18
  "scripts": {
19
19
  "build": "npm-run-all --serial clean build:types build:js build:barrel",
@@ -22,12 +22,17 @@
22
22
  "build:types": "tsc",
23
23
  "clean": "rimraf dist types coverage",
24
24
  "lint": "biome lint src",
25
- "test": "cross-env-shell NODE_OPTIONS=--experimental-vm-modules jest",
26
- "test:coverage": "npm run test -- --coverage",
25
+ "test": "vitest run --globals",
26
+ "test:coverage": "vitest run --coverage --globals",
27
+ "test:watch": "vitest --globals",
27
28
  "watch": "swc --strip-leading-paths --watch --out-dir dist src"
28
29
  },
29
30
  "publishConfig": {
30
31
  "access": "public"
31
32
  },
32
- "gitHead": "d7d79f8f71fb3225e5a214aba3a42a89470d8340"
33
+ "devDependencies": {
34
+ "@vitest/coverage-v8": "3.2.4",
35
+ "vitest": "3.2.4"
36
+ },
37
+ "gitHead": "2cef8f88aa5316a1789caad2bd7327ca908ccb9f"
33
38
  }