@thi.ng/bench 3.5.5 → 3.5.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/CHANGELOG.md +7 -1
- package/README.md +2 -2
- package/format/markdown.js +14 -14
- package/package.json +9 -9
- package/profiler.js +5 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-06-21T19:34:38Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
### [3.5.7](https://github.com/thi-ng/umbrella/tree/@thi.ng/bench@3.5.7) (2024-06-21)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
|
|
17
|
+
|
|
12
18
|
### [3.5.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/bench@3.5.1) (2024-03-27)
|
|
13
19
|
|
|
14
20
|
#### 🩹 Bug fixes
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 193 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
|
@@ -84,7 +84,7 @@ For Node.js REPL:
|
|
|
84
84
|
const bench = await import("@thi.ng/bench");
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 2.
|
|
87
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 2.14 KB
|
|
88
88
|
|
|
89
89
|
## Dependencies
|
|
90
90
|
|
package/format/markdown.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { EMPTY, FLOAT } from "../api.js";
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const column =
|
|
2
|
+
const __n = (n, char = "-") => new Array(n).fill(char).join("");
|
|
3
|
+
const __pad = (w) => {
|
|
4
|
+
const column = __n(w, " ");
|
|
5
5
|
return (x) => {
|
|
6
6
|
const s = typeof x === "number" ? FLOAT(x) : x;
|
|
7
7
|
return s.length < w ? column.substring(0, w - s.length) + s : s.substring(0, w);
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
10
|
+
const __row = (cols) => `|${cols.map((x, i) => COLUMNS[i](x)).join("|")}|`;
|
|
11
|
+
const C24 = __pad(24);
|
|
12
|
+
const C12 = __pad(12);
|
|
13
|
+
const C8 = __pad(8);
|
|
14
|
+
const D24 = __n(24);
|
|
15
|
+
const D12 = __n(11) + ":";
|
|
16
|
+
const D8 = __n(7) + ":";
|
|
17
|
+
const COLUMNS = [C24, C8, C8, C12, C12, C8, C8, C8, C8, C8, C8, C8];
|
|
18
|
+
const DASHES = [D24, D8, D8, D12, D12, D8, D8, D8, D8, D8, D8, D8];
|
|
19
19
|
const FORMAT_MD = {
|
|
20
|
-
prefix: () =>
|
|
20
|
+
prefix: () => __row([
|
|
21
21
|
"Title",
|
|
22
22
|
"Iter",
|
|
23
23
|
"Size",
|
|
@@ -34,7 +34,7 @@ const FORMAT_MD = {
|
|
|
34
34
|
|${DASHES.join("|")}|`,
|
|
35
35
|
start: EMPTY,
|
|
36
36
|
warmup: EMPTY,
|
|
37
|
-
result: (res) =>
|
|
37
|
+
result: (res) => __row([
|
|
38
38
|
res.title,
|
|
39
39
|
"" + res.iter,
|
|
40
40
|
"" + res.size,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/bench",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.7",
|
|
4
4
|
"description": "Benchmarking & profiling utilities w/ various statistics & formatters (CSV, JSON, Markdown etc.)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.11.
|
|
39
|
+
"@thi.ng/api": "^8.11.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@microsoft/api-extractor": "^7.
|
|
43
|
-
"@thi.ng/testament": "^0.4.
|
|
44
|
-
"@types/node": "^20.
|
|
45
|
-
"esbuild": "^0.
|
|
42
|
+
"@microsoft/api-extractor": "^7.47.0",
|
|
43
|
+
"@thi.ng/testament": "^0.4.30",
|
|
44
|
+
"@types/node": "^20.14.6",
|
|
45
|
+
"esbuild": "^0.21.5",
|
|
46
46
|
"tools": "^0.0.1",
|
|
47
|
-
"typedoc": "^0.25.
|
|
48
|
-
"typescript": "^5.
|
|
47
|
+
"typedoc": "^0.25.13",
|
|
48
|
+
"typescript": "^5.5.2"
|
|
49
49
|
},
|
|
50
50
|
"keywords": [
|
|
51
51
|
"benchmark",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
],
|
|
120
120
|
"year": 2018
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
|
|
123
123
|
}
|
package/profiler.js
CHANGED
|
@@ -8,8 +8,7 @@ class Profiler {
|
|
|
8
8
|
constructor(opts = {}) {
|
|
9
9
|
const { warmup = 1e6, enabled = true } = opts;
|
|
10
10
|
this.enable();
|
|
11
|
-
if (warmup > 0)
|
|
12
|
-
this.warmup(warmup);
|
|
11
|
+
if (warmup > 0) this.warmup(warmup);
|
|
13
12
|
enabled ? this.reset() : this.disable();
|
|
14
13
|
}
|
|
15
14
|
isEnabled() {
|
|
@@ -62,8 +61,7 @@ class Profiler {
|
|
|
62
61
|
*/
|
|
63
62
|
deref() {
|
|
64
63
|
const { _profiles, _session, _overhead } = this;
|
|
65
|
-
if (!_session)
|
|
66
|
-
return {};
|
|
64
|
+
if (!_session) return {};
|
|
67
65
|
const res = {};
|
|
68
66
|
const sessionTotal = asMillis(_session.total) - _session.calls * _overhead;
|
|
69
67
|
for (let id in _profiles) {
|
|
@@ -130,8 +128,7 @@ class Profiler {
|
|
|
130
128
|
* @param id
|
|
131
129
|
*/
|
|
132
130
|
start(id) {
|
|
133
|
-
if (!this._enabled)
|
|
134
|
-
return;
|
|
131
|
+
if (!this._enabled) return;
|
|
135
132
|
let profile = this._profiles[id];
|
|
136
133
|
const t0 = now();
|
|
137
134
|
if (!profile) {
|
|
@@ -159,12 +156,10 @@ class Profiler {
|
|
|
159
156
|
* @param id
|
|
160
157
|
*/
|
|
161
158
|
end(id) {
|
|
162
|
-
if (!this._enabled)
|
|
163
|
-
return;
|
|
159
|
+
if (!this._enabled) return;
|
|
164
160
|
const t = now();
|
|
165
161
|
const profile = this._profiles[id];
|
|
166
|
-
if (!profile)
|
|
167
|
-
throw new Error(`invalid profile ID: ${id}`);
|
|
162
|
+
if (!profile) throw new Error(`invalid profile ID: ${id}`);
|
|
168
163
|
const t1 = profile.t0.pop();
|
|
169
164
|
if (t1 === void 0)
|
|
170
165
|
throw new Error(`no active profile for ID: ${id}`);
|