@cobol-ts/metrics 0.0.14 → 0.0.16

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.
Files changed (2) hide show
  1. package/README.md +23 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,9 +1,28 @@
1
1
  # @cobol-ts/metrics
2
2
 
3
- A deliberately minimal operation-counter interface: `IPutMetrics.put(name)`. Pass one instance down from the file-reader options. The default `NULL_METRICS` does nothing and does not allocate or log in the hot path. `MemoryMetrics` increments named counts in a Map; use `get`, `snapshot`, and `reset` outside hot paths. Names are static constants in `METRIC`.
3
+ Expose constant-name, opt-in operation counters for projection and cursor hot paths.
4
4
 
5
- Counters report **actual operations**, not elapsed time. The `*.visit` counters count loop iterations (and can therefore expose non-linear cleanup). A counter value is not itself evidence of heap allocation: allocation counters are placed only on explicit construction branches. Reset after warm-up to isolate the measured run. Metrics distort throughput and should be disabled when comparing timing.
5
+ Counters reflect explicit `put` calls, not bytes allocated or wall-clock timings.
6
6
 
7
- ## Interpretation with shared-binding arrays
7
+ ## Example
8
8
 
9
- Counter names reflect the chosen execution path. For an eligible native fixed array, `array.proxy.index`, `array.element.select`, and `array.child.bind` may correctly remain zero while the application reads every occurrence. The common root projection is still bound, and scalar decoder invocations continue to count actual requested reads. For a lazy Proxy array, the corresponding selection and child-cache counters remain meaningful. Compare metrics only for equivalent execution strategies and do not equate counter reductions with speedups.
9
+ ```typescript
10
+ import {MemoryMetrics, METRIC} from '@cobol-ts/metrics'
11
+
12
+ const metrics = new MemoryMetrics()
13
+ metrics.put(METRIC.RECORD_BORROW)
14
+ metrics.put(METRIC.RECORD_BORROW)
15
+ const borrows = metrics.get(METRIC.RECORD_BORROW) // 2
16
+ const snapshot = metrics.snapshot() // detached from later resets
17
+ metrics.reset()
18
+ ```
19
+
20
+ Use `NULL_METRICS` in production when operation counters are disabled. Names in `METRIC` are fixed literals so instrumented hot paths do not format labels per record. These counters report operations, not allocated bytes or elapsed time.
21
+
22
+ ## Source and tests
23
+
24
+ **Public entry points:** [metrics.ts](./src/metrics.ts).
25
+
26
+ **Tests:** [metrics.spec.ts](src/metrics.spec.ts)
27
+
28
+ **Related:** [@cobol-ts/cursor-projection](../../cursor-loader/projection/README.md) · [@cobol-ts/cursor-loader-benchmark](../../cursor-loader/cursor-loader-benchmark/README.md).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cobol-ts/metrics",
3
3
  "description": "Allocation-light named operation counters",
4
- "version": "0.0.14",
4
+ "version": "0.0.16",
5
5
  "main": "dist/index",
6
6
  "types": "dist/index",
7
7
  "browserslist": {