@universal-packages/time-measurer 1.4.10 → 1.5.0
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/TimeMeasurer.d.ts +1 -0
- package/TimeMeasurer.js +15 -2
- package/TimeMeasurer.js.map +1 -1
- package/package.json +2 -2
package/TimeMeasurer.d.ts
CHANGED
package/TimeMeasurer.js
CHANGED
@@ -13,14 +13,27 @@ const Measurement_1 = __importDefault(require("./Measurement"));
|
|
13
13
|
class TimeMeasurer {
|
14
14
|
constructor() {
|
15
15
|
this.hrStart = 0n;
|
16
|
+
this.startTime = 0;
|
16
17
|
}
|
17
18
|
/** Resets the initial time */
|
18
19
|
start() {
|
19
|
-
|
20
|
+
if (typeof process !== 'undefined' && process.hrtime) {
|
21
|
+
this.hrStart = process.hrtime.bigint();
|
22
|
+
}
|
23
|
+
else {
|
24
|
+
this.startTime = performance.now();
|
25
|
+
}
|
20
26
|
}
|
21
27
|
/** Returns a measurement representing the time passed from when start was called */
|
22
28
|
finish() {
|
23
|
-
|
29
|
+
let nanoseconds;
|
30
|
+
if (typeof process !== 'undefined' && process.hrtime) {
|
31
|
+
nanoseconds = process.hrtime.bigint() - this.hrStart;
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
const milliseconds = performance.now() - this.startTime;
|
35
|
+
nanoseconds = BigInt(Math.round(milliseconds * 1e6));
|
36
|
+
}
|
24
37
|
return new Measurement_1.default(nanoseconds);
|
25
38
|
}
|
26
39
|
}
|
package/TimeMeasurer.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TimeMeasurer.js","sourceRoot":"","sources":["../src/TimeMeasurer.ts"],"names":[],"mappings":";;;;;AAAA,gEAAuC;AAEvC;;;;;GAKG;AACH,MAAqB,YAAY;IAAjC;QACU,YAAO,GAAW,EAAE,CAAA;
|
1
|
+
{"version":3,"file":"TimeMeasurer.js","sourceRoot":"","sources":["../src/TimeMeasurer.ts"],"names":[],"mappings":";;;;;AAAA,gEAAuC;AAEvC;;;;;GAKG;AACH,MAAqB,YAAY;IAAjC;QACU,YAAO,GAAW,EAAE,CAAA;QACpB,cAAS,GAAW,CAAC,CAAA;IAuB/B,CAAC;IArBC,8BAA8B;IACvB,KAAK;QACV,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACrD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA;QACxC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;QACpC,CAAC;IACH,CAAC;IAED,oFAAoF;IAC7E,MAAM;QACX,IAAI,WAAmB,CAAA;QACvB,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACrD,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAA;QACtD,CAAC;aAAM,CAAC;YACN,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAA;YACvD,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC,CAAA;QACtD,CAAC;QAED,OAAO,IAAI,qBAAW,CAAC,WAAW,CAAC,CAAA;IACrC,CAAC;CACF;AAzBD,+BAyBC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@universal-packages/time-measurer",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.5.0",
|
4
4
|
"description": "Utility to measure routines times with precision",
|
5
5
|
"author": "David De Anda <david@universal-packages.com> (https://github.com/universal-packages)",
|
6
6
|
"license": "MIT",
|
@@ -19,7 +19,7 @@
|
|
19
19
|
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
20
20
|
"@types/jest": "^29.5.12",
|
21
21
|
"@types/node": "^18.11.9",
|
22
|
-
"@universal-packages/maintenance": "^1.6.
|
22
|
+
"@universal-packages/maintenance": "^1.6.9",
|
23
23
|
"jest": "^29.7.0",
|
24
24
|
"prettier": "^3.0.3",
|
25
25
|
"ts-jest": "^29.1.2",
|