@thi.ng/bench 3.6.7 → 3.6.8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-12-12T10:11:58Z
3
+ - **Last updated**: 2024-12-27T14:11:37Z
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,15 @@ 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.6.8](https://github.com/thi-ng/umbrella/tree/@thi.ng/bench@3.6.8) (2024-12-27)
13
+
14
+ #### ♻️ Refactoring
15
+
16
+ - migrate timestamp fns to [@thi.ng/timestamp](https://github.com/thi-ng/umbrella/tree/main/packages/timestamp) ([f178b1a](https://github.com/thi-ng/umbrella/commit/f178b1a))
17
+ - update deps
18
+ - update exports
19
+ - update readme
20
+
12
21
  ## [3.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/bench@3.6.0) (2024-08-10)
13
22
 
14
23
  #### 🚀 Features
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  > [!NOTE]
10
- > This is one of 199 standalone projects, maintained as part
10
+ > This is one of 200 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
  >
@@ -33,19 +33,10 @@
33
33
 
34
34
  Benchmarking & profiling utilities w/ various statistics & formatters (CSV, JSON, Markdown etc.).
35
35
 
36
- Though no public API change (only additions), since v2.0.0 this library
37
- internally (via
38
- [`now()`](https://docs.thi.ng/umbrella/bench/functions/now.html)) attempts to
39
- use high-res ES
40
- [`BigInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)
41
- timestamps (in Node via
42
- [`process.hrtime.bigint()`](https://nodejs.org/dist/latest-v12.x/docs/api/process.html#process_process_hrtime_bigint))
43
- or falls back to `performance.now()` or lacking that to `Date.now()`. In all
44
- cases, returns a (possibly rounded) nanosec-scale timestamp, either as `bigint`
45
- or `number`. The
46
- [`timeDiff()`](https://docs.thi.ng/umbrella/bench/functions/timeDiff.html)
47
- function can be used to compute the difference between two such timestamp and
48
- return it as milliseconds.
36
+ > [!IMPORTANT]
37
+ > As of 2024-12-27, all timestamp-related functions have been extracted/migrated
38
+ > to the new [@thi.ng/timestamp](https://thi.ng/timestamp) package, but are
39
+ > still available here as re-exports too.
49
40
 
50
41
  ## Status
51
42
 
@@ -84,11 +75,12 @@ For Node.js REPL:
84
75
  const bench = await import("@thi.ng/bench");
85
76
  ```
86
77
 
87
- Package sizes (brotli'd, pre-treeshake): ESM: 2.14 KB
78
+ Package sizes (brotli'd, pre-treeshake): ESM: 2.06 KB
88
79
 
89
80
  ## Dependencies
90
81
 
91
82
  - [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/develop/packages/api)
83
+ - [@thi.ng/timestamp](https://github.com/thi-ng/umbrella/tree/develop/packages/timestamp)
92
84
 
93
85
  Note: @thi.ng/api is in _most_ cases a type-only import (not used at runtime)
94
86
 
package/api.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Fn, Fn0, Fn2 } from "@thi.ng/api";
2
- export type Timestamp = number | bigint;
2
+ export type { Timestamp } from "@thi.ng/timestamp";
3
3
  export type TimingResult<T> = [T, number];
4
4
  export interface BenchmarkOpts {
5
5
  /**
package/now.d.ts CHANGED
@@ -1,24 +1,2 @@
1
- import type { Fn0 } from "@thi.ng/api";
2
- import type { Timestamp } from "./api.js";
3
- /**
4
- * If available, returns wrapper for `process.hrtime.bigint()` else falls back
5
- * to `performance.now()` or lacking that to `Date.now()`. In all cases, returns
6
- * a nanosec-scale timestamp, either as `bigint` or `number`.
7
- */
8
- export declare const now: Fn0<Timestamp>;
9
- /**
10
- * Returns the difference in milliseconds between 2 given {@link Timestamp}s.
11
- * `b` defaults to result of {@link now}.
12
- *
13
- * @param a
14
- * @param b
15
- */
16
- export declare const timeDiff: (a: Timestamp, b?: Timestamp) => number;
17
- /**
18
- * Takes a duration (either a number or bigint) in nanosec-scale (see
19
- * {@link now}) and converts it to a JS number in milliseconds.
20
- *
21
- * @param t
22
- */
23
- export declare const asMillis: (t: number | bigint) => number;
1
+ export { asMillis, now, timeDiff } from "@thi.ng/timestamp";
24
2
  //# sourceMappingURL=now.d.ts.map
package/now.js CHANGED
@@ -1,6 +1,4 @@
1
- const now = typeof BigInt !== "undefined" ? typeof process !== "undefined" && typeof process.hrtime !== "undefined" && typeof process.hrtime.bigint === "function" ? () => process.hrtime.bigint() : typeof performance !== "undefined" ? () => BigInt(Math.floor(performance.now() * 1e6)) : () => BigInt(Date.now() * 1e6) : typeof performance !== "undefined" ? () => performance.now() * 1e6 : () => Date.now() * 1e6;
2
- const timeDiff = (a, b = now()) => (typeof BigInt !== "undefined" ? Number(b - a) : b - a) * 1e-6;
3
- const asMillis = (t) => (typeof t === "bigint" ? Number(t) : t) * 1e-6;
1
+ import { asMillis, now, timeDiff } from "@thi.ng/timestamp";
4
2
  export {
5
3
  asMillis,
6
4
  now,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/bench",
3
- "version": "3.6.7",
3
+ "version": "3.6.8",
4
4
  "description": "Benchmarking & profiling utilities w/ various statistics & formatters (CSV, JSON, Markdown etc.)",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -19,6 +19,10 @@
19
19
  {
20
20
  "type": "patreon",
21
21
  "url": "https://patreon.com/thing_umbrella"
22
+ },
23
+ {
24
+ "type": "liberapay",
25
+ "url": "https://liberapay.com/thi.ng"
22
26
  }
23
27
  ],
24
28
  "author": "Karsten Schmidt <k+npm@thi.ng>",
@@ -36,14 +40,15 @@
36
40
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
41
  },
38
42
  "dependencies": {
39
- "@thi.ng/api": "^8.11.14"
43
+ "@thi.ng/api": "^8.11.15",
44
+ "@thi.ng/timestamp": "^1.1.0"
40
45
  },
41
46
  "devDependencies": {
42
- "@microsoft/api-extractor": "^7.48.0",
43
- "@types/node": "^22.10.1",
44
- "esbuild": "^0.24.0",
47
+ "@microsoft/api-extractor": "^7.48.1",
48
+ "@types/node": "^22.10.2",
49
+ "esbuild": "^0.24.2",
45
50
  "tools": "^0.0.1",
46
- "typedoc": "^0.27.4",
51
+ "typedoc": "^0.27.6",
47
52
  "typescript": "^5.7.2"
48
53
  },
49
54
  "keywords": [
@@ -57,6 +62,7 @@
57
62
  "statistics",
58
63
  "table",
59
64
  "time",
65
+ "timestamp",
60
66
  "typescript"
61
67
  ],
62
68
  "publishConfig": {
@@ -116,5 +122,5 @@
116
122
  ],
117
123
  "year": 2018
118
124
  },
119
- "gitHead": "34ac95538d96f046090fef5fd3a1dc36d54663d5\n"
125
+ "gitHead": "48bf4c22bf23f88ac99f435106af2214f79a0be1\n"
120
126
  }