@xylabs/profile 5.0.83 → 5.0.86

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/README.md CHANGED
@@ -15,6 +15,8 @@
15
15
 
16
16
  Base functionality used throughout XY Labs TypeScript/JavaScript libraries
17
17
 
18
+
19
+
18
20
  ## Reference
19
21
 
20
22
  **@xylabs/profile**
@@ -23,13 +25,17 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
23
25
 
24
26
  ## Type Aliases
25
27
 
26
- - [Profiler](#type-aliases/Profiler)
28
+ | Type Alias | Description |
29
+ | ------ | ------ |
30
+ | [Profiler](#type-aliases/Profiler) | A record of named timing entries, where each key maps to an array of timestamps. |
27
31
 
28
32
  ## Functions
29
33
 
30
- - [createProfiler](#functions/createProfiler)
31
- - [profile](#functions/profile)
32
- - [profileReport](#functions/profileReport)
34
+ | Function | Description |
35
+ | ------ | ------ |
36
+ | [createProfiler](#functions/createProfiler) | Creates a new empty profiler instance. |
37
+ | [profile](#functions/profile) | Records a timestamp for the given profile name. |
38
+ | [profileReport](#functions/profileReport) | Generates a report of elapsed times for each profiled entry. |
33
39
 
34
40
  ### functions
35
41
 
@@ -43,6 +49,8 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
43
49
  function createProfiler(): Profiler;
44
50
  ```
45
51
 
52
+ Creates a new empty profiler instance.
53
+
46
54
  ## Returns
47
55
 
48
56
  [`Profiler`](#../type-aliases/Profiler)
@@ -54,18 +62,17 @@ function createProfiler(): Profiler;
54
62
  ***
55
63
 
56
64
  ```ts
57
- function profile(profiler, name): void;
65
+ function profile(profiler: Profiler, name: string): void;
58
66
  ```
59
67
 
60
- ## Parameters
61
-
62
- ### profiler
63
-
64
- [`Profiler`](#../type-aliases/Profiler)
68
+ Records a timestamp for the given profile name.
65
69
 
66
- ### name
70
+ ## Parameters
67
71
 
68
- `string`
72
+ | Parameter | Type | Description |
73
+ | ------ | ------ | ------ |
74
+ | `profiler` | [`Profiler`](#../type-aliases/Profiler) | The profiler instance to record into. |
75
+ | `name` | `string` | The name of the timing entry. |
69
76
 
70
77
  ## Returns
71
78
 
@@ -78,19 +85,23 @@ function profile(profiler, name): void;
78
85
  ***
79
86
 
80
87
  ```ts
81
- function profileReport(profiler): Record<string, number>;
88
+ function profileReport(profiler: Profiler): Record<string, number>;
82
89
  ```
83
90
 
84
- ## Parameters
91
+ Generates a report of elapsed times for each profiled entry.
85
92
 
86
- ### profiler
93
+ ## Parameters
87
94
 
88
- [`Profiler`](#../type-aliases/Profiler)
95
+ | Parameter | Type | Description |
96
+ | ------ | ------ | ------ |
97
+ | `profiler` | [`Profiler`](#../type-aliases/Profiler) | The profiler instance to report on. |
89
98
 
90
99
  ## Returns
91
100
 
92
101
  `Record`\<`string`, `number`\>
93
102
 
103
+ A record mapping each profile name to its elapsed time in milliseconds, plus a '-all-' total.
104
+
94
105
  ### type-aliases
95
106
 
96
107
  ### <a id="Profiler"></a>Profiler
@@ -103,6 +114,8 @@ function profileReport(profiler): Record<string, number>;
103
114
  type Profiler = Record<string, number[]>;
104
115
  ```
105
116
 
117
+ A record of named timing entries, where each key maps to an array of timestamps.
118
+
106
119
 
107
120
  Part of [sdk-js](https://www.npmjs.com/package/@xyo-network/sdk-js)
108
121
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/profiler.ts"],"sourcesContent":["export type Profiler = Record<string, number[]>\n\nexport const createProfiler = (): Profiler => {\n return {}\n}\n\nexport const profile = (profiler: Profiler, name: string) => {\n const timeData = profiler[name] ?? []\n timeData.push(Date.now())\n profiler[name] = timeData\n}\n\nexport const profileReport = (profiler: Profiler) => {\n let lowest = Date.now()\n let highest = 0\n // eslint-disable-next-line unicorn/no-array-reduce\n const results = Object.entries(profiler).reduce<Record<string, number>>((prev, [name, readings]) => {\n const start = readings.at(0)\n if (start !== undefined) {\n if (start < lowest) {\n lowest = start\n }\n const end = readings.at(-1) ?? Date.now()\n if (end > highest) {\n highest = end\n }\n prev[name] = end - start\n }\n return prev\n }, {})\n if (highest > 0) {\n results['-all-'] = highest - lowest\n }\n return results\n}\n"],"mappings":";AAEO,IAAM,iBAAiB,MAAgB;AAC5C,SAAO,CAAC;AACV;AAEO,IAAM,UAAU,CAAC,UAAoB,SAAiB;AAC3D,QAAM,WAAW,SAAS,IAAI,KAAK,CAAC;AACpC,WAAS,KAAK,KAAK,IAAI,CAAC;AACxB,WAAS,IAAI,IAAI;AACnB;AAEO,IAAM,gBAAgB,CAAC,aAAuB;AACnD,MAAI,SAAS,KAAK,IAAI;AACtB,MAAI,UAAU;AAEd,QAAM,UAAU,OAAO,QAAQ,QAAQ,EAAE,OAA+B,CAAC,MAAM,CAAC,MAAM,QAAQ,MAAM;AAClG,UAAM,QAAQ,SAAS,GAAG,CAAC;AAC3B,QAAI,UAAU,QAAW;AACvB,UAAI,QAAQ,QAAQ;AAClB,iBAAS;AAAA,MACX;AACA,YAAM,MAAM,SAAS,GAAG,EAAE,KAAK,KAAK,IAAI;AACxC,UAAI,MAAM,SAAS;AACjB,kBAAU;AAAA,MACZ;AACA,WAAK,IAAI,IAAI,MAAM;AAAA,IACrB;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAC;AACL,MAAI,UAAU,GAAG;AACf,YAAQ,OAAO,IAAI,UAAU;AAAA,EAC/B;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/profiler.ts"],"sourcesContent":["/** A record of named timing entries, where each key maps to an array of timestamps. */\nexport type Profiler = Record<string, number[]>\n\n/** Creates a new empty profiler instance. */\nexport const createProfiler = (): Profiler => {\n return {}\n}\n\n/**\n * Records a timestamp for the given profile name.\n * @param profiler - The profiler instance to record into.\n * @param name - The name of the timing entry.\n */\nexport const profile = (profiler: Profiler, name: string) => {\n const timeData = profiler[name] ?? []\n timeData.push(Date.now())\n profiler[name] = timeData\n}\n\n/**\n * Generates a report of elapsed times for each profiled entry.\n * @param profiler - The profiler instance to report on.\n * @returns A record mapping each profile name to its elapsed time in milliseconds, plus a '-all-' total.\n */\nexport const profileReport = (profiler: Profiler) => {\n let lowest = Date.now()\n let highest = 0\n // eslint-disable-next-line unicorn/no-array-reduce\n const results = Object.entries(profiler).reduce<Record<string, number>>((prev, [name, readings]) => {\n const start = readings.at(0)\n if (start !== undefined) {\n if (start < lowest) {\n lowest = start\n }\n const end = readings.at(-1) ?? Date.now()\n if (end > highest) {\n highest = end\n }\n prev[name] = end - start\n }\n return prev\n }, {})\n if (highest > 0) {\n results['-all-'] = highest - lowest\n }\n return results\n}\n"],"mappings":";AAIO,IAAM,iBAAiB,MAAgB;AAC5C,SAAO,CAAC;AACV;AAOO,IAAM,UAAU,CAAC,UAAoB,SAAiB;AAC3D,QAAM,WAAW,SAAS,IAAI,KAAK,CAAC;AACpC,WAAS,KAAK,KAAK,IAAI,CAAC;AACxB,WAAS,IAAI,IAAI;AACnB;AAOO,IAAM,gBAAgB,CAAC,aAAuB;AACnD,MAAI,SAAS,KAAK,IAAI;AACtB,MAAI,UAAU;AAEd,QAAM,UAAU,OAAO,QAAQ,QAAQ,EAAE,OAA+B,CAAC,MAAM,CAAC,MAAM,QAAQ,MAAM;AAClG,UAAM,QAAQ,SAAS,GAAG,CAAC;AAC3B,QAAI,UAAU,QAAW;AACvB,UAAI,QAAQ,QAAQ;AAClB,iBAAS;AAAA,MACX;AACA,YAAM,MAAM,SAAS,GAAG,EAAE,KAAK,KAAK,IAAI;AACxC,UAAI,MAAM,SAAS;AACjB,kBAAU;AAAA,MACZ;AACA,WAAK,IAAI,IAAI,MAAM;AAAA,IACrB;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAC;AACL,MAAI,UAAU,GAAG;AACf,YAAQ,OAAO,IAAI,UAAU;AAAA,EAC/B;AACA,SAAO;AACT;","names":[]}
@@ -1,5 +1,17 @@
1
+ /** A record of named timing entries, where each key maps to an array of timestamps. */
1
2
  export type Profiler = Record<string, number[]>;
3
+ /** Creates a new empty profiler instance. */
2
4
  export declare const createProfiler: () => Profiler;
5
+ /**
6
+ * Records a timestamp for the given profile name.
7
+ * @param profiler - The profiler instance to record into.
8
+ * @param name - The name of the timing entry.
9
+ */
3
10
  export declare const profile: (profiler: Profiler, name: string) => void;
11
+ /**
12
+ * Generates a report of elapsed times for each profiled entry.
13
+ * @param profiler - The profiler instance to report on.
14
+ * @returns A record mapping each profile name to its elapsed time in milliseconds, plus a '-all-' total.
15
+ */
4
16
  export declare const profileReport: (profiler: Profiler) => Record<string, number>;
5
17
  //# sourceMappingURL=profiler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"profiler.d.ts","sourceRoot":"","sources":["../../src/profiler.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;AAE/C,eAAO,MAAM,cAAc,QAAO,QAEjC,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,UAAU,QAAQ,EAAE,MAAM,MAAM,SAIvD,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,UAAU,QAAQ,2BAsB/C,CAAA"}
1
+ {"version":3,"file":"profiler.d.ts","sourceRoot":"","sources":["../../src/profiler.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;AAE/C,6CAA6C;AAC7C,eAAO,MAAM,cAAc,QAAO,QAEjC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,UAAU,QAAQ,EAAE,MAAM,MAAM,SAIvD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,UAAU,QAAQ,2BAsB/C,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/profile",
3
- "version": "5.0.83",
3
+ "version": "5.0.86",
4
4
  "description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
5
5
  "keywords": [
6
6
  "profile",
@@ -43,8 +43,8 @@
43
43
  "!**/*.test.*"
44
44
  ],
45
45
  "devDependencies": {
46
- "@xylabs/ts-scripts-yarn3": "~7.4.11",
47
- "@xylabs/tsconfig": "~7.4.11",
46
+ "@xylabs/ts-scripts-yarn3": "~7.4.16",
47
+ "@xylabs/tsconfig": "~7.4.16",
48
48
  "typescript": "~5.9.3",
49
49
  "vitest": "^4.0.18"
50
50
  },