@node-cli/perf 1.0.2 → 1.0.3
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.js.map +1 -1
- package/package.json +3 -3
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/* istanbul ignore next */ () => {\n\t\t\t\tperformance.clearMeasures();\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/* 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"],"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-cli/perf",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"description": "Set of performance tools for Node.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"node": ">=16",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@node-cli/logger": ">=1.
|
|
15
|
+
"@node-cli/logger": ">=1.2.0",
|
|
16
16
|
"@node-cli/utilities": ">=1.0.0"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "b50d3ef336c6ba247ea5eea568ec5cf6b7da9fd3"
|
|
33
33
|
}
|