@universal-packages/time-measurer 1.6.0 → 2.0.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.
@@ -0,0 +1,71 @@
1
+ import { Measurement } from './Measurement';
2
+ import { ProfilerCheckpoint, ProfilerOptions } from './TimeProfiler.types';
3
+ export declare class TimeProfiler {
4
+ readonly options: ProfilerOptions;
5
+ private startTime;
6
+ private isStarted;
7
+ private _checkpoints;
8
+ private lastMemoryUsage;
9
+ /**
10
+ * Get all checkpoints recorded so far
11
+ * @returns Array of all checkpoints
12
+ */
13
+ get checkpoints(): ProfilerCheckpoint[];
14
+ /**
15
+ * Get the last checkpoint recorded
16
+ * @returns The most recent checkpoint, or undefined if none
17
+ */
18
+ get lastCheckpoint(): ProfilerCheckpoint | undefined;
19
+ /**
20
+ * Check if the profiler is currently running
21
+ * @returns True if started, false otherwise
22
+ */
23
+ get isRunning(): boolean;
24
+ /**
25
+ * Get the total elapsed time since start
26
+ * @returns Current measurement from start, or undefined if not started
27
+ */
28
+ get elapsed(): Measurement | undefined;
29
+ constructor(options?: ProfilerOptions);
30
+ /**
31
+ * Get a specific checkpoint by name
32
+ * @param name - Name of the checkpoint to find
33
+ * @returns The checkpoint, or undefined if not found
34
+ */
35
+ getCheckpoint(name: string): ProfilerCheckpoint | undefined;
36
+ /**
37
+ * Start the profiler session
38
+ * @throws Error if already started
39
+ */
40
+ start(): void;
41
+ /**
42
+ * Create a checkpoint measurement from the start time
43
+ * @param name - Name/label for this checkpoint
44
+ * @returns The measurement from start to this checkpoint
45
+ * @throws Error if not started
46
+ */
47
+ checkpoint(name: string): Measurement;
48
+ /**
49
+ * Stop the profiler and get final summary
50
+ * @param finalCheckpointName - Optional name for the final checkpoint
51
+ * @returns Array of all checkpoints including the final one
52
+ */
53
+ stop(finalCheckpointName?: string): ProfilerCheckpoint[];
54
+ /**
55
+ * Reset the profiler to start a new session
56
+ */
57
+ reset(): void;
58
+ /**
59
+ * Get current memory usage in bytes
60
+ * @returns Memory usage in bytes, or 0 if unavailable
61
+ */
62
+ private getCurrentMemoryUsage;
63
+ /**
64
+ * Create a quick profiler that auto-starts
65
+ * @param name - Name for the profiler session
66
+ * @param autoLog - Whether to auto-log checkpoints
67
+ * @returns Started TimeProfiler instance
68
+ */
69
+ static start(name?: string): TimeProfiler;
70
+ }
71
+ //# sourceMappingURL=TimeProfiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimeProfiler.d.ts","sourceRoot":"","sources":["../src/TimeProfiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE1E,qBAAa,YAAY;IACvB,SAAgB,OAAO,EAAE,eAAe,CAAA;IAExC,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,eAAe,CAAY;IAEnC;;;OAGG;IACH,IAAW,WAAW,IAAI,kBAAkB,EAAE,CAE7C;IAED;;;OAGG;IACH,IAAW,cAAc,IAAI,kBAAkB,GAAG,SAAS,CAE1D;IAED;;;OAGG;IACH,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED;;;OAGG;IACH,IAAW,OAAO,IAAI,WAAW,GAAG,SAAS,CAc5C;gBAEW,OAAO,CAAC,EAAE,eAAe;IAQrC;;;;OAIG;IACI,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIlE;;;OAGG;IACI,KAAK,IAAI,IAAI;IAoBpB;;;;;OAKG;IACI,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW;IAwC5C;;;;OAIG;IACI,IAAI,CAAC,mBAAmB,GAAE,MAAgB,GAAG,kBAAkB,EAAE;IAaxE;;OAEG;IACI,KAAK,IAAI,IAAI;IAOpB;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAS7B;;;;;OAKG;WACW,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY;CAKjD"}
@@ -0,0 +1,171 @@
1
+ import { Measurement } from './Measurement';
2
+ export class TimeProfiler {
3
+ options;
4
+ startTime = 0;
5
+ isStarted = false;
6
+ _checkpoints = [];
7
+ lastMemoryUsage = 0;
8
+ /**
9
+ * Get all checkpoints recorded so far
10
+ * @returns Array of all checkpoints
11
+ */
12
+ get checkpoints() {
13
+ return [...this._checkpoints];
14
+ }
15
+ /**
16
+ * Get the last checkpoint recorded
17
+ * @returns The most recent checkpoint, or undefined if none
18
+ */
19
+ get lastCheckpoint() {
20
+ return this._checkpoints[this._checkpoints.length - 1];
21
+ }
22
+ /**
23
+ * Check if the profiler is currently running
24
+ * @returns True if started, false otherwise
25
+ */
26
+ get isRunning() {
27
+ return this.isStarted;
28
+ }
29
+ /**
30
+ * Get the total elapsed time since start
31
+ * @returns Current measurement from start, or undefined if not started
32
+ */
33
+ get elapsed() {
34
+ if (!this.isStarted) {
35
+ return undefined;
36
+ }
37
+ let nanoseconds;
38
+ if (typeof process !== 'undefined' && process.hrtime && typeof this.startTime === 'bigint') {
39
+ nanoseconds = process.hrtime.bigint() - this.startTime;
40
+ }
41
+ else {
42
+ const milliseconds = performance.now() - this.startTime;
43
+ nanoseconds = BigInt(Math.round(milliseconds * 1e6));
44
+ }
45
+ return new Measurement(nanoseconds);
46
+ }
47
+ constructor(options) {
48
+ this.options = {
49
+ name: 'Profiler Session',
50
+ trackMemory: false,
51
+ ...options
52
+ };
53
+ }
54
+ /**
55
+ * Get a specific checkpoint by name
56
+ * @param name - Name of the checkpoint to find
57
+ * @returns The checkpoint, or undefined if not found
58
+ */
59
+ getCheckpoint(name) {
60
+ return this._checkpoints.find((cp) => cp.name === name);
61
+ }
62
+ /**
63
+ * Start the profiler session
64
+ * @throws Error if already started
65
+ */
66
+ start() {
67
+ if (this.isStarted) {
68
+ throw new Error('Profiler already started. Call reset() to start a new session.');
69
+ }
70
+ if (typeof process !== 'undefined' && process.hrtime) {
71
+ this.startTime = process.hrtime.bigint();
72
+ }
73
+ else {
74
+ this.startTime = performance.now();
75
+ }
76
+ this.isStarted = true;
77
+ this._checkpoints = [];
78
+ // Initialize memory tracking if enabled
79
+ if (this.options.trackMemory) {
80
+ this.lastMemoryUsage = this.getCurrentMemoryUsage();
81
+ }
82
+ }
83
+ /**
84
+ * Create a checkpoint measurement from the start time
85
+ * @param name - Name/label for this checkpoint
86
+ * @returns The measurement from start to this checkpoint
87
+ * @throws Error if not started
88
+ */
89
+ checkpoint(name) {
90
+ if (!this.isStarted) {
91
+ throw new Error('Profiler not started. Call start() first.');
92
+ }
93
+ let nanoseconds;
94
+ if (typeof process !== 'undefined' && process.hrtime && typeof this.startTime === 'bigint') {
95
+ nanoseconds = process.hrtime.bigint() - this.startTime;
96
+ }
97
+ else {
98
+ const milliseconds = performance.now() - this.startTime;
99
+ nanoseconds = BigInt(Math.round(milliseconds * 1e6));
100
+ }
101
+ const measurement = new Measurement(nanoseconds);
102
+ const checkpoint = {
103
+ name,
104
+ measurement,
105
+ timestamp: new Date()
106
+ };
107
+ // Add memory tracking if enabled
108
+ if (this.options.trackMemory) {
109
+ const currentMemory = this.getCurrentMemoryUsage();
110
+ checkpoint.memoryUsage = currentMemory;
111
+ // First checkpoint has delta 0, subsequent ones have delta from previous
112
+ if (this._checkpoints.length === 0) {
113
+ checkpoint.memoryDelta = 0;
114
+ }
115
+ else {
116
+ checkpoint.memoryDelta = currentMemory - this.lastMemoryUsage;
117
+ }
118
+ this.lastMemoryUsage = currentMemory;
119
+ }
120
+ this._checkpoints.push(checkpoint);
121
+ return measurement;
122
+ }
123
+ /**
124
+ * Stop the profiler and get final summary
125
+ * @param finalCheckpointName - Optional name for the final checkpoint
126
+ * @returns Array of all checkpoints including the final one
127
+ */
128
+ stop(finalCheckpointName = 'Final') {
129
+ if (!this.isStarted) {
130
+ throw new Error('Profiler not started.');
131
+ }
132
+ // Add final checkpoint
133
+ this.checkpoint(finalCheckpointName);
134
+ this.isStarted = false;
135
+ return this.checkpoints;
136
+ }
137
+ /**
138
+ * Reset the profiler to start a new session
139
+ */
140
+ reset() {
141
+ this.isStarted = false;
142
+ this.startTime = 0;
143
+ this._checkpoints = [];
144
+ this.lastMemoryUsage = 0;
145
+ }
146
+ /**
147
+ * Get current memory usage in bytes
148
+ * @returns Memory usage in bytes, or 0 if unavailable
149
+ */
150
+ getCurrentMemoryUsage() {
151
+ if (typeof process !== 'undefined' && process.memoryUsage) {
152
+ return process.memoryUsage().heapUsed;
153
+ }
154
+ else if (typeof performance !== 'undefined' && performance.memory) {
155
+ return performance.memory.usedJSHeapSize || 0;
156
+ }
157
+ return 0;
158
+ }
159
+ /**
160
+ * Create a quick profiler that auto-starts
161
+ * @param name - Name for the profiler session
162
+ * @param autoLog - Whether to auto-log checkpoints
163
+ * @returns Started TimeProfiler instance
164
+ */
165
+ static start(name) {
166
+ const profiler = new TimeProfiler({ name });
167
+ profiler.start();
168
+ return profiler;
169
+ }
170
+ }
171
+ //# sourceMappingURL=TimeProfiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimeProfiler.js","sourceRoot":"","sources":["../src/TimeProfiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAG3C,MAAM,OAAO,YAAY;IACP,OAAO,CAAiB;IAEhC,SAAS,GAAoB,CAAC,CAAA;IAC9B,SAAS,GAAY,KAAK,CAAA;IAC1B,YAAY,GAAyB,EAAE,CAAA;IACvC,eAAe,GAAW,CAAC,CAAA;IAEnC;;;OAGG;IACH,IAAW,WAAW;QACpB,OAAO,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,CAAA;IAC/B,CAAC;IAED;;;OAGG;IACH,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;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IAAI,CAAC,CAAA;QACxD,CAAC;QACD,OAAO,CAAC,CAAA;IACV,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,IAAa;QAC/B,MAAM,QAAQ,GAAG,IAAI,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;QAC3C,QAAQ,CAAC,KAAK,EAAE,CAAA;QAChB,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import { Measurement } from './Measurement';
2
+ export interface ProfilerCheckpoint {
3
+ /** Name/label for this checkpoint */
4
+ name: string;
5
+ /** Measurement from start to this checkpoint */
6
+ measurement: Measurement;
7
+ /** Timestamp when this checkpoint was created */
8
+ timestamp: Date;
9
+ /** Memory usage at this checkpoint in bytes (if tracking enabled) */
10
+ memoryUsage?: number;
11
+ /** Memory delta from previous checkpoint in bytes (if tracking enabled) */
12
+ memoryDelta?: number;
13
+ }
14
+ export interface ProfilerOptions {
15
+ /** Name for this profiler session */
16
+ name?: string;
17
+ /** Whether to track memory usage deltas between checkpoints */
18
+ trackMemory?: boolean;
19
+ }
20
+ //# sourceMappingURL=TimeProfiler.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimeProfiler.types.d.ts","sourceRoot":"","sources":["../src/TimeProfiler.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,WAAW,kBAAkB;IACjC,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,gDAAgD;IAChD,WAAW,EAAE,WAAW,CAAA;IACxB,iDAAiD;IACjD,SAAS,EAAE,IAAI,CAAA;IACf,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,+DAA+D;IAC/D,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TimeProfiler.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimeProfiler.types.js","sourceRoot":"","sources":["../src/TimeProfiler.types.ts"],"names":[],"mappings":""}
package/index.d.ts CHANGED
@@ -1,5 +1,9 @@
1
- export { default as TimeMeasurer } from './TimeMeasurer';
2
- export { default as Measurement } from './Measurement';
1
+ export * from './TimeMeasurer';
2
+ export * from './Measurement';
3
3
  export * from './Measurement.types';
4
- export { default as sleep } from './sleep';
5
- export * from './startMeasurement';
4
+ export * from './Benchmark';
5
+ export * from './Benchmark.types';
6
+ export * from './TimeProfiler';
7
+ export * from './TimeProfiler.types';
8
+ export * from './Sleep';
9
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,SAAS,CAAA"}
package/index.js CHANGED
@@ -1,29 +1,9 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.sleep = exports.Measurement = exports.TimeMeasurer = void 0;
21
- var TimeMeasurer_1 = require("./TimeMeasurer");
22
- Object.defineProperty(exports, "TimeMeasurer", { enumerable: true, get: function () { return __importDefault(TimeMeasurer_1).default; } });
23
- var Measurement_1 = require("./Measurement");
24
- Object.defineProperty(exports, "Measurement", { enumerable: true, get: function () { return __importDefault(Measurement_1).default; } });
25
- __exportStar(require("./Measurement.types"), exports);
26
- var sleep_1 = require("./sleep");
27
- Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return __importDefault(sleep_1).default; } });
28
- __exportStar(require("./startMeasurement"), exports);
1
+ export * from './TimeMeasurer';
2
+ export * from './Measurement';
3
+ export * from './Measurement.types';
4
+ export * from './Benchmark';
5
+ export * from './Benchmark.types';
6
+ export * from './TimeProfiler';
7
+ export * from './TimeProfiler.types';
8
+ export * from './Sleep';
29
9
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,+CAAwD;AAA/C,6HAAA,OAAO,OAAgB;AAChC,6CAAsD;AAA7C,2HAAA,OAAO,OAAe;AAC/B,sDAAmC;AACnC,iCAA0C;AAAjC,+GAAA,OAAO,OAAS;AACzB,qDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,SAAS,CAAA"}
package/package.json CHANGED
@@ -1,38 +1,37 @@
1
1
  {
2
2
  "name": "@universal-packages/time-measurer",
3
- "version": "1.6.0",
3
+ "version": "2.0.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",
7
7
  "main": "index.js",
8
8
  "types": "index.d.ts",
9
+ "type": "module",
9
10
  "repository": "git@github.com:universal-packages/universal-time-measurer.git",
10
11
  "scripts": {
11
12
  "build": "tsc --p tsconfig.dis.json",
12
- "test": "jest --watch",
13
- "test:coverage": "jest --coverage",
14
- "test:clear": "jest --clearCache",
15
- "format": "prettier --write \"./{src,tests}/**/*.{ts,tsx,js,jsx,json}\"",
16
- "update-universal-dependencies": "umaintenance update-universal-dependencies"
13
+ "test": "tsx ./src/tests.test.ts",
14
+ "test:coverage": "c8 --reporter=text --reporter=json --reporter=html --reporter=lcov --reporter=text-summary tsx ./src/tests.test.ts",
15
+ "test:watch": "tsx watch ./src/tests.test.ts",
16
+ "format": "prettier --write",
17
+ "format:all": "npm run format \"./**/*.{ts,tsx,js,jsx,json}\"",
18
+ "update-universal-dependencies": "umaintenance update-universal-dependencies",
19
+ "prepare": "husky"
17
20
  },
18
- "devDependencies": {
19
- "@trivago/prettier-plugin-sort-imports": "^4.3.0",
20
- "@types/jest": "^29.5.14",
21
- "@types/node": "^18.11.9",
22
- "@universal-packages/maintenance": "^1.6.12",
23
- "jest": "^29.7.0",
24
- "prettier": "^3.4.1",
25
- "ts-jest": "^29.2.5",
26
- "typescript": "^5.7.2"
21
+ "dependencies": {
22
+ "ms": "^2.1.3"
27
23
  },
28
- "jest": {
29
- "preset": "ts-jest",
30
- "collectCoverageFrom": [
31
- "src/**/*.ts"
32
- ],
33
- "setupFilesAfterEnv": [
34
- "<rootDir>/tests/setup.ts"
35
- ]
24
+ "devDependencies": {
25
+ "@trivago/prettier-plugin-sort-imports": "^5.2.2",
26
+ "@types/ms": "^2.1.0",
27
+ "@types/node": "^22.15.17",
28
+ "@universal-packages/maintenance": "^1.7.4",
29
+ "@universal-packages/tsconfig": "^1.0.2",
30
+ "c8": "^10.1.3",
31
+ "husky": "^9.1.7",
32
+ "prettier": "^3.5.3",
33
+ "tsx": "^4.19.4",
34
+ "typescript": "^5.8.3"
36
35
  },
37
36
  "prettier": {
38
37
  "semi": false,
package/sleep.d.ts DELETED
@@ -1,2 +0,0 @@
1
- /** Simple awaitable timeout to sleep the process */
2
- export default function sleep(milliseconds: number): Promise<void>;
package/sleep.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = sleep;
4
- /** Simple awaitable timeout to sleep the process */
5
- async function sleep(milliseconds) {
6
- return new Promise((resolve) => setTimeout(() => resolve(), milliseconds));
7
- }
8
- //# sourceMappingURL=sleep.js.map
package/sleep.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"sleep.js","sourceRoot":"","sources":["../src/sleep.ts"],"names":[],"mappings":";;AACA,wBAEC;AAHD,oDAAoD;AACrC,KAAK,UAAU,KAAK,CAAC,YAAoB;IACtD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAkB,EAAE,CAAC,UAAU,CAAC,GAAS,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC,CAAA;AAClG,CAAC"}
@@ -1,2 +0,0 @@
1
- import TimeMeasurer from './TimeMeasurer';
2
- export declare function startMeasurement(): TimeMeasurer;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.startMeasurement = startMeasurement;
7
- const TimeMeasurer_1 = __importDefault(require("./TimeMeasurer"));
8
- function startMeasurement() {
9
- const measurer = new TimeMeasurer_1.default();
10
- measurer.start();
11
- return measurer;
12
- }
13
- //# sourceMappingURL=startMeasurement.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"startMeasurement.js","sourceRoot":"","sources":["../src/startMeasurement.ts"],"names":[],"mappings":";;;;;AAEA,4CAMC;AARD,kEAAyC;AAEzC,SAAgB,gBAAgB;IAC9B,MAAM,QAAQ,GAAG,IAAI,sBAAY,EAAE,CAAA;IAEnC,QAAQ,CAAC,KAAK,EAAE,CAAA;IAEhB,OAAO,QAAQ,CAAA;AACjB,CAAC"}