@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.
- package/dist/performance.d.ts +0 -1
- package/dist/performance.js +1 -1
- package/dist/performance.js.map +1 -1
- package/package.json +11 -6
package/dist/performance.d.ts
CHANGED
package/dist/performance.js
CHANGED
|
@@ -9,7 +9,7 @@ export class Performance {
|
|
|
9
9
|
startMarkerName;
|
|
10
10
|
measureName;
|
|
11
11
|
constructor(){
|
|
12
|
-
this.perfObserver = new PerformanceObserver(/*
|
|
12
|
+
this.perfObserver = new PerformanceObserver(/* v8 ignore next 2 */ ()=>{
|
|
13
13
|
performance.clearMeasures();
|
|
14
14
|
});
|
|
15
15
|
this.perfObserver.observe({
|
package/dist/performance.js.map
CHANGED
|
@@ -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/*
|
|
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.
|
|
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.
|
|
16
|
-
"@node-cli/utilities": "1.0.
|
|
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": "
|
|
26
|
-
"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
|
-
"
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
35
|
+
"vitest": "3.2.4"
|
|
36
|
+
},
|
|
37
|
+
"gitHead": "2cef8f88aa5316a1789caad2bd7327ca908ccb9f"
|
|
33
38
|
}
|