@thi.ng/bench 3.1.22 → 3.2.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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2022-12-22T21:47:07Z
3
+ - **Last updated**: 2023-02-05T14:42:21Z
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,13 @@ 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.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/bench@3.2.0) (2023-02-05)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add support for performance.now() ([f48cb35](https://github.com/thi-ng/umbrella/commit/f48cb35))
17
+ - update now() to add perf.now as primary fallback option
18
+
12
19
  ## [3.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/bench@3.1.0) (2021-11-17)
13
20
 
14
21
  #### 🚀 Features
package/README.md CHANGED
@@ -27,12 +27,18 @@ This project is part of the
27
27
  Benchmarking utilities w/ various statistics & formatters (CSV, Markdown etc.).
28
28
 
29
29
  Though no public API change (only additions), since v2.0.0 this library
30
- internally attempts to use high-res ES
30
+ internally (via
31
+ [`now()`](https://docs.thi.ng/umbrella/bench/functions/now.html)) attempts to
32
+ use high-res ES
31
33
  [`BigInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)
32
34
  timestamps (in Node via
33
- [`process.hrtime.bigint()`](https://nodejs.org/dist/latest-v12.x/docs/api/process.html#process_process_hrtime_bigint)).
34
- If `BigInt` is not available in the target environment, timestamps are still
35
- only sourced via `Date.now()`.
35
+ [`process.hrtime.bigint()`](https://nodejs.org/dist/latest-v12.x/docs/api/process.html#process_process_hrtime_bigint))
36
+ or falls back to `performance.now()` or lacking that to `Date.now()`. In all
37
+ cases, returns a (possibly rounded) nanosec-scale timestamp, either as `bigint`
38
+ or `number`. The
39
+ [`timeDiff()`](https://docs.thi.ng/umbrella/bench/functions/timeDiff.html)
40
+ function can be used to compute the difference between two such timestamp and
41
+ return it as milliseconds.
36
42
 
37
43
  ## Status
38
44
 
@@ -65,7 +71,7 @@ For Node.js REPL:
65
71
  const bench = await import("@thi.ng/bench");
66
72
  ```
67
73
 
68
- Package sizes (brotli'd, pre-treeshake): ESM: 1.25 KB
74
+ Package sizes (brotli'd, pre-treeshake): ESM: 1.27 KB
69
75
 
70
76
  ## Dependencies
71
77
 
@@ -82,6 +88,7 @@ A selection:
82
88
  | Screenshot | Description | Live demo | Source |
83
89
  |:--------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:---------------------------------------------------------|:--------------------------------------------------------------------------------------|
84
90
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/geom-knn.jpg" width="240"/> | Doodle w/ K-nearest neighbor search result visualization | [Demo](https://demo.thi.ng/umbrella/geom-knn/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/geom-knn) |
91
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/geom-knn-hash.jpg" width="240"/> | K-nearest neighbor search in an hash grid | [Demo](https://demo.thi.ng/umbrella/geom-knn-hash/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/geom-knn-hash) |
85
92
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/geom-voronoi-mst.jpg" width="240"/> | Poisson-disk shape-aware sampling, Voronoi & Minimum Spanning Tree visualization | [Demo](https://demo.thi.ng/umbrella/geom-voronoi-mst/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/geom-voronoi-mst) |
86
93
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/markdown-parser.jpg" width="240"/> | Minimal Markdown to Hiccup to HTML parser / transformer | [Demo](https://demo.thi.ng/umbrella/markdown/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/markdown) |
87
94
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/parse-playground.png" width="240"/> | Parser grammar livecoding editor/playground & codegen | [Demo](https://demo.thi.ng/umbrella/parse-playground/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/parse-playground) |
@@ -224,4 +231,4 @@ If this project contributes to an academic publication, please cite it as:
224
231
 
225
232
  ## License
226
233
 
227
- &copy; 2018 - 2022 Karsten Schmidt // Apache License 2.0
234
+ &copy; 2018 - 2023 Karsten Schmidt // Apache License 2.0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../src/format/csv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAgB,MAAM,WAAW,CAAC;AAE7D,eAAO,MAAM,UAAU,EAAE,kBAmBxB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../src/format/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAgB,MAAM,WAAW,CAAC;AAE7D,eAAO,MAAM,cAAc,EAAE,kBAe5B,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/format/markdown.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAgB,MAAM,WAAW,CAAC;AA4B7D,eAAO,MAAM,SAAS,EAAE,kBAiCvB,CAAC"}
package/now.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import type { Fn0, FnU2 } from "@thi.ng/api";
2
2
  import type { Timestamp } from "./api.js";
3
3
  /**
4
- * If available, returns wrapper for `process.hrtime.bigint()` else
5
- * falls back to `Date.now()`. In all cases, returns a nanosec-scale
6
- * timestamp, either as `bigint` or `number`.
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
7
  */
8
8
  export declare const now: Fn0<Timestamp>;
9
9
  /**
package/now.js CHANGED
@@ -1,15 +1,19 @@
1
1
  /**
2
- * If available, returns wrapper for `process.hrtime.bigint()` else
3
- * falls back to `Date.now()`. In all cases, returns a nanosec-scale
4
- * timestamp, either as `bigint` or `number`.
2
+ * If available, returns wrapper for `process.hrtime.bigint()` else falls back
3
+ * to `performance.now()` or lacking that to `Date.now()`. In all cases, returns
4
+ * a nanosec-scale timestamp, either as `bigint` or `number`.
5
5
  */
6
6
  export const now = typeof BigInt !== "undefined"
7
7
  ? typeof process !== "undefined" &&
8
8
  typeof process.hrtime !== "undefined" &&
9
9
  typeof process.hrtime.bigint === "function"
10
10
  ? () => process.hrtime.bigint()
11
- : () => BigInt(Date.now() * 1e6)
12
- : () => Date.now() * 1e6;
11
+ : typeof performance !== "undefined"
12
+ ? () => BigInt(Math.floor(performance.now() * 1e6))
13
+ : () => BigInt(Date.now() * 1e6)
14
+ : typeof performance !== "undefined"
15
+ ? () => performance.now() * 1e6
16
+ : () => Date.now() * 1e6;
13
17
  /**
14
18
  * Returns the difference in milliseconds between 2 given
15
19
  * {@link Timestamp}s.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/bench",
3
- "version": "3.1.22",
3
+ "version": "3.2.0",
4
4
  "description": "Benchmarking utilities w/ various statistics & formatters (CSV, Markdown etc.)",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -34,16 +34,16 @@
34
34
  "test": "testament test"
35
35
  },
36
36
  "dependencies": {
37
- "@thi.ng/api": "^8.6.2"
37
+ "@thi.ng/api": "^8.7.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@microsoft/api-extractor": "^7.33.7",
41
- "@thi.ng/testament": "^0.3.8",
42
- "@types/node": "^18.11.13",
43
- "rimraf": "^3.0.2",
40
+ "@microsoft/api-extractor": "^7.34.2",
41
+ "@thi.ng/testament": "^0.3.10",
42
+ "@types/node": "^18.11.18",
43
+ "rimraf": "^4.1.2",
44
44
  "tools": "^0.0.1",
45
- "typedoc": "^0.23.22",
46
- "typescript": "^4.9.4"
45
+ "typedoc": "^0.23.24",
46
+ "typescript": "^4.9.5"
47
47
  },
48
48
  "keywords": [
49
49
  "benchmark",
@@ -114,5 +114,5 @@
114
114
  ],
115
115
  "year": 2018
116
116
  },
117
- "gitHead": "bc6f7f5e2765bb96fe64db804eaf4b2443b47fc6\n"
117
+ "gitHead": "50ba9c87676fac60c46d2bc0e4d2c7711a374a68\n"
118
118
  }