@thi.ng/bench 3.5.4 → 3.5.6
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 +1 -1
- package/README.md +1 -1
- package/package.json +10 -11
- package/profiler.js +5 -10
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/bench",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.6",
|
|
4
4
|
"description": "Benchmarking & profiling utilities w/ various statistics & formatters (CSV, JSON, Markdown etc.)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"build": "yarn build:esbuild && yarn build:decl",
|
|
28
28
|
"build:decl": "tsc --declaration --emitDeclarationOnly",
|
|
29
29
|
"build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
|
|
30
|
-
"clean": "
|
|
30
|
+
"clean": "bun ../../tools/src/clean-package.ts format",
|
|
31
31
|
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
32
32
|
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
33
33
|
"doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
|
|
@@ -36,17 +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.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@microsoft/api-extractor": "^7.43.
|
|
43
|
-
"@thi.ng/testament": "^0.4.
|
|
44
|
-
"@types/node": "^20.11
|
|
45
|
-
"esbuild": "^0.
|
|
46
|
-
"rimraf": "^5.0.5",
|
|
42
|
+
"@microsoft/api-extractor": "^7.43.2",
|
|
43
|
+
"@thi.ng/testament": "^0.4.29",
|
|
44
|
+
"@types/node": "^20.12.11",
|
|
45
|
+
"esbuild": "^0.21.1",
|
|
47
46
|
"tools": "^0.0.1",
|
|
48
|
-
"typedoc": "^0.25.
|
|
49
|
-
"typescript": "^5.4.
|
|
47
|
+
"typedoc": "^0.25.13",
|
|
48
|
+
"typescript": "^5.4.5"
|
|
50
49
|
},
|
|
51
50
|
"keywords": [
|
|
52
51
|
"benchmark",
|
|
@@ -120,5 +119,5 @@
|
|
|
120
119
|
],
|
|
121
120
|
"year": 2018
|
|
122
121
|
},
|
|
123
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
|
|
124
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}`);
|