@cobol-ts/cli-benchmark 0.0.0-stage → 0.0.57

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 (123) hide show
  1. package/README.md +9 -3
  2. package/dist/index.d.ts +10 -0
  3. package/dist/index.js +27 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/src/benchmark.access.spec.d.ts +1 -0
  6. package/dist/src/benchmark.access.spec.js +30 -0
  7. package/dist/src/benchmark.access.spec.js.map +1 -0
  8. package/dist/src/benchmark.aggregate.fixture.d.ts +10 -0
  9. package/dist/src/benchmark.aggregate.fixture.js +110 -0
  10. package/dist/src/benchmark.aggregate.fixture.js.map +1 -0
  11. package/dist/src/benchmark.allocations.d.ts +19 -0
  12. package/dist/src/benchmark.allocations.js +83 -0
  13. package/dist/src/benchmark.allocations.js.map +1 -0
  14. package/dist/src/benchmark.allocations.spec.d.ts +1 -0
  15. package/dist/src/benchmark.allocations.spec.js +64 -0
  16. package/dist/src/benchmark.allocations.spec.js.map +1 -0
  17. package/dist/src/benchmark.builder.d.ts +8 -0
  18. package/dist/src/benchmark.builder.js +21 -0
  19. package/dist/src/benchmark.builder.js.map +1 -0
  20. package/dist/src/benchmark.calibration.spec.d.ts +1 -0
  21. package/dist/src/benchmark.calibration.spec.js +83 -0
  22. package/dist/src/benchmark.calibration.spec.js.map +1 -0
  23. package/dist/src/benchmark.command.d.ts +8 -0
  24. package/dist/src/benchmark.command.js +368 -0
  25. package/dist/src/benchmark.command.js.map +1 -0
  26. package/dist/src/benchmark.composed.fixture.d.ts +4 -0
  27. package/dist/src/benchmark.composed.fixture.js +80 -0
  28. package/dist/src/benchmark.composed.fixture.js.map +1 -0
  29. package/dist/src/benchmark.composed.fixture.spec.d.ts +1 -0
  30. package/dist/src/benchmark.composed.fixture.spec.js +52 -0
  31. package/dist/src/benchmark.composed.fixture.spec.js.map +1 -0
  32. package/dist/src/benchmark.composed.runner.d.ts +14 -0
  33. package/dist/src/benchmark.composed.runner.js +197 -0
  34. package/dist/src/benchmark.composed.runner.js.map +1 -0
  35. package/dist/src/benchmark.composed.two.fixture.d.ts +5 -0
  36. package/dist/src/benchmark.composed.two.fixture.js +118 -0
  37. package/dist/src/benchmark.composed.two.fixture.js.map +1 -0
  38. package/dist/src/benchmark.configuration.d.ts +19 -0
  39. package/dist/src/benchmark.configuration.js +111 -0
  40. package/dist/src/benchmark.configuration.js.map +1 -0
  41. package/dist/src/benchmark.configuration.spec.d.ts +1 -0
  42. package/dist/src/benchmark.configuration.spec.js +28 -0
  43. package/dist/src/benchmark.configuration.spec.js.map +1 -0
  44. package/dist/src/benchmark.dependencies.d.ts +37 -0
  45. package/dist/src/benchmark.dependencies.js +3 -0
  46. package/dist/src/benchmark.dependencies.js.map +1 -0
  47. package/dist/src/benchmark.engine.d.ts +31 -0
  48. package/dist/src/benchmark.engine.js +47 -0
  49. package/dist/src/benchmark.engine.js.map +1 -0
  50. package/dist/src/benchmark.engine.spec.d.ts +1 -0
  51. package/dist/src/benchmark.engine.spec.js +116 -0
  52. package/dist/src/benchmark.engine.spec.js.map +1 -0
  53. package/dist/src/benchmark.execution.d.ts +22 -0
  54. package/dist/src/benchmark.execution.js +64 -0
  55. package/dist/src/benchmark.execution.js.map +1 -0
  56. package/dist/src/benchmark.execution.spec.d.ts +1 -0
  57. package/dist/src/benchmark.execution.spec.js +74 -0
  58. package/dist/src/benchmark.execution.spec.js.map +1 -0
  59. package/dist/src/benchmark.format.fixture.d.ts +26 -0
  60. package/dist/src/benchmark.format.fixture.js +186 -0
  61. package/dist/src/benchmark.format.fixture.js.map +1 -0
  62. package/dist/src/benchmark.format.oracle.d.ts +8 -0
  63. package/dist/src/benchmark.format.oracle.js +30 -0
  64. package/dist/src/benchmark.format.oracle.js.map +1 -0
  65. package/dist/src/benchmark.format.runner.d.ts +8 -0
  66. package/dist/src/benchmark.format.runner.js +202 -0
  67. package/dist/src/benchmark.format.runner.js.map +1 -0
  68. package/dist/src/benchmark.format.source.d.ts +5 -0
  69. package/dist/src/benchmark.format.source.js +16 -0
  70. package/dist/src/benchmark.format.source.js.map +1 -0
  71. package/dist/src/benchmark.gc.d.ts +39 -0
  72. package/dist/src/benchmark.gc.js +83 -0
  73. package/dist/src/benchmark.gc.js.map +1 -0
  74. package/dist/src/benchmark.gc.spec.d.ts +1 -0
  75. package/dist/src/benchmark.gc.spec.js +50 -0
  76. package/dist/src/benchmark.gc.spec.js.map +1 -0
  77. package/dist/src/benchmark.history.d.ts +15 -0
  78. package/dist/src/benchmark.history.js +71 -0
  79. package/dist/src/benchmark.history.js.map +1 -0
  80. package/dist/src/benchmark.init.d.ts +6 -0
  81. package/dist/src/benchmark.init.js +34 -0
  82. package/dist/src/benchmark.init.js.map +1 -0
  83. package/dist/src/benchmark.measurement.d.ts +15 -0
  84. package/dist/src/benchmark.measurement.js +15 -0
  85. package/dist/src/benchmark.measurement.js.map +1 -0
  86. package/dist/src/benchmark.options.d.ts +29 -0
  87. package/dist/src/benchmark.options.js +53 -0
  88. package/dist/src/benchmark.options.js.map +1 -0
  89. package/dist/src/benchmark.periodic.fixture.d.ts +5 -0
  90. package/dist/src/benchmark.periodic.fixture.js +71 -0
  91. package/dist/src/benchmark.periodic.fixture.js.map +1 -0
  92. package/dist/src/benchmark.periodic.fixture.spec.d.ts +1 -0
  93. package/dist/src/benchmark.periodic.fixture.spec.js +97 -0
  94. package/dist/src/benchmark.periodic.fixture.spec.js.map +1 -0
  95. package/dist/src/benchmark.profile.d.ts +9 -0
  96. package/dist/src/benchmark.profile.js +68 -0
  97. package/dist/src/benchmark.profile.js.map +1 -0
  98. package/dist/src/benchmark.profile.spec.d.ts +1 -0
  99. package/dist/src/benchmark.profile.spec.js +65 -0
  100. package/dist/src/benchmark.profile.spec.js.map +1 -0
  101. package/dist/src/benchmark.record.d.ts +16 -0
  102. package/dist/src/benchmark.record.js +34 -0
  103. package/dist/src/benchmark.record.js.map +1 -0
  104. package/dist/src/benchmark.report.d.ts +131 -0
  105. package/dist/src/benchmark.report.edges.spec.d.ts +1 -0
  106. package/dist/src/benchmark.report.edges.spec.js +25 -0
  107. package/dist/src/benchmark.report.edges.spec.js.map +1 -0
  108. package/dist/src/benchmark.report.js +372 -0
  109. package/dist/src/benchmark.report.js.map +1 -0
  110. package/dist/src/benchmark.report.spec.d.ts +1 -0
  111. package/dist/src/benchmark.report.spec.js +304 -0
  112. package/dist/src/benchmark.report.spec.js.map +1 -0
  113. package/dist/src/benchmark.runner.d.ts +30 -0
  114. package/dist/src/benchmark.runner.js +257 -0
  115. package/dist/src/benchmark.runner.js.map +1 -0
  116. package/dist/src/benchmark.state.digest.d.ts +7 -0
  117. package/dist/src/benchmark.state.digest.js +28 -0
  118. package/dist/src/benchmark.state.digest.js.map +1 -0
  119. package/dist/src/benchmark.state.digest.spec.d.ts +1 -0
  120. package/dist/src/benchmark.state.digest.spec.js +30 -0
  121. package/dist/src/benchmark.state.digest.spec.js.map +1 -0
  122. package/index.ts +10 -0
  123. package/package.json +81 -3
@@ -0,0 +1,304 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const benchmark_report_1 = require("./benchmark.report");
4
+ const example = () => (0, benchmark_report_1.createBenchmarkReport)({
5
+ project: 'fixture', node: '24', v8: '13', warmupRecords: 100,
6
+ loader: [
7
+ { records: 1000, totalMs: 2, celMs: 0 },
8
+ { records: 1000, totalMs: 3, celMs: 0 },
9
+ { records: 1000, totalMs: 4, celMs: 0 }
10
+ ],
11
+ integrated: [
12
+ { records: 1000, totalMs: 4, celMs: 1 },
13
+ { records: 1000, totalMs: 5, celMs: 2 },
14
+ { records: 1000, totalMs: 6, celMs: 1.5 }
15
+ ]
16
+ });
17
+ describe('benchmark reporting', () => {
18
+ it('computes measurements from elapsed time and retains per-pass values', () => {
19
+ const result = example();
20
+ expect(result).toEqual({
21
+ project: 'fixture', node: '24', v8: '13', records: 1000, runs: 3, warmupRecords: 100,
22
+ passes: [
23
+ { run: 1,
24
+ loader: { records: 1000, elapsedMs: 2, recordsPerSecond: 500000, nsPerRecord: 2000 },
25
+ integrated: { records: 1000, elapsedMs: 4, recordsPerSecond: 250000, nsPerRecord: 4000,
26
+ celNsPerRecord: 1000, nonCelNsPerRecord: 3000 } },
27
+ { run: 2,
28
+ loader: { records: 1000, elapsedMs: 3, recordsPerSecond: 1000000 / 3, nsPerRecord: 3000 },
29
+ integrated: { records: 1000, elapsedMs: 5, recordsPerSecond: 200000, nsPerRecord: 5000,
30
+ celNsPerRecord: 2000, nonCelNsPerRecord: 3000 } },
31
+ { run: 3,
32
+ loader: { records: 1000, elapsedMs: 4, recordsPerSecond: 250000, nsPerRecord: 4000 },
33
+ integrated: { records: 1000, elapsedMs: 6, recordsPerSecond: 1000000 / 6, nsPerRecord: 6000,
34
+ celNsPerRecord: 1500, nonCelNsPerRecord: 4500 } }
35
+ ],
36
+ summary: {
37
+ loader: { records: 1000, elapsedMs: 3, recordsPerSecond: 1000000 / 3, nsPerRecord: 3000 },
38
+ integrated: { records: 1000, elapsedMs: 5, recordsPerSecond: 200000, nsPerRecord: 5000,
39
+ celMedianNsPerRecord: 1500, celMinNsPerRecord: 1000, celMaxNsPerRecord: 2000,
40
+ nonCelNsPerRecord: 3000, throughputChangePercent: 40 }
41
+ }
42
+ });
43
+ });
44
+ it('renders exactly the same measurement in human-readable units', () => {
45
+ expect((0, benchmark_report_1.formatBenchmarkReport)(example())).toEqual([
46
+ 'BENCHMARK project=fixture records=1,000 runs=3 node=24 v8=13',
47
+ 'WARMUP records=100',
48
+ 'PASS LOADER rec/s LOADER ns/rec CEL ns/rec WITH CEL rec/s TOTAL ns/rec',
49
+ ' 1 500,000 2000.0 1000.0 250,000 4000.0',
50
+ ' 2 333,333 3000.0 2000.0 200,000 5000.0',
51
+ ' 3 250,000 4000.0 1500.0 166,667 6000.0',
52
+ '---------------------------------------------------------------------------',
53
+ 'Average 361,111 3000.0 1500.0 205,556 5000.0',
54
+ 'SUMMARY (median of 3 runs; higher throughput is better)',
55
+ ' Read : 333,333 rec/s',
56
+ ' With CEL : 200,000 rec/s',
57
+ ' CEL execution : 1.50 µs/rec (range 1.00–2.00 µs/rec)'
58
+ ]);
59
+ });
60
+ it('formats the same output incrementally as the completed report', () => {
61
+ const report = example();
62
+ expect([
63
+ ...(0, benchmark_report_1.formatBenchmarkStart)({ ...report, withCel: true }),
64
+ ...report.passes.map(benchmark_report_1.formatBenchmarkPass),
65
+ ...(0, benchmark_report_1.formatBenchmarkAverage)(report),
66
+ ...(0, benchmark_report_1.formatBenchmarkSummary)(report)
67
+ ]).toEqual((0, benchmark_report_1.formatBenchmarkReport)(report));
68
+ });
69
+ it('reports the separate projection throughput when measured', () => {
70
+ const report = (0, benchmark_report_1.createBenchmarkReport)({ project: 'projection', node: '24', v8: '13', warmupRecords: 0,
71
+ loader: [{ records: 1000, totalMs: 2, celMs: 0 }],
72
+ projection: [{ records: 1000, totalMs: 4, celMs: 0 }]
73
+ });
74
+ expect((0, benchmark_report_1.formatBenchmarkProjectionSummary)(report)).toEqual([' Project : 250,000 rec/s']);
75
+ expect((0, benchmark_report_1.formatBenchmarkProjectionSummary)(example())).toEqual([]);
76
+ });
77
+ it('supports a loader-only handmade project', () => {
78
+ const result = (0, benchmark_report_1.createBenchmarkReport)({ project: 'custom', node: '24', v8: '13', warmupRecords: 0,
79
+ loader: [{ records: 2, totalMs: 1, celMs: 0 }] });
80
+ expect((0, benchmark_report_1.formatBenchmarkReport)(result)).toEqual([
81
+ 'BENCHMARK project=custom records=2 runs=1 node=24 v8=13',
82
+ 'WARMUP records=0',
83
+ 'PASS LOADER rec/s LOADER ns/rec',
84
+ ' 1 2,000 500000.0',
85
+ '------------------------------------',
86
+ 'Average 2,000 500000.0',
87
+ 'SUMMARY (median of 1 run; higher throughput is better)',
88
+ ' Read : 2,000 rec/s'
89
+ ]);
90
+ });
91
+ it('rejects invalid pass timings and mismatched measurements', () => {
92
+ const base = { project: 'x', node: '24', v8: '13', warmupRecords: 0 };
93
+ expect(() => (0, benchmark_report_1.createBenchmarkReport)({ ...base, loader: [] })).toThrow('Benchmark pass counts do not match');
94
+ expect(() => (0, benchmark_report_1.createBenchmarkReport)({ ...base,
95
+ loader: [{ records: 1, totalMs: 2, celMs: 0 }],
96
+ integrated: [{ records: 1, totalMs: 2, celMs: 3 }] })).toThrow('Invalid benchmark measurement');
97
+ expect(() => (0, benchmark_report_1.createBenchmarkReport)({ ...base,
98
+ loader: [{ records: 2, totalMs: 2, celMs: 0 }],
99
+ integrated: [{ records: 1, totalMs: 2, celMs: 0 }] })).toThrow('Benchmark record counts do not match');
100
+ });
101
+ });
102
+ describe('benchmark suite reporting', () => {
103
+ it('compares benchmark medians without aggregating independent throughputs', () => {
104
+ const first = example();
105
+ const second = (0, benchmark_report_1.createBenchmarkReport)({
106
+ project: 'C:\\benchmarks\\graph-100', node: '24', v8: '13', warmupRecords: 100,
107
+ loader: [{ records: 2000, totalMs: 8, celMs: 0 }],
108
+ integrated: [{ records: 2000, totalMs: 20, celMs: 12 }]
109
+ });
110
+ const third = (0, benchmark_report_1.createBenchmarkReport)({
111
+ project: 'graph-1000', node: '24', v8: '13', warmupRecords: 100,
112
+ loader: [{ records: 3000, totalMs: 6, celMs: 0 }]
113
+ });
114
+ // Exact lines are asserted below using the production formatter.
115
+ const summary = (0, benchmark_report_1.formatBenchmarkSuiteSummary)([first, second, third]);
116
+ expect(summary).toEqual([
117
+ "",
118
+ "ALL SUMMARY (throughput from median elapsed time; higher rec/s is better)",
119
+ "BENCHMARK RECORDS READ rec/s PROJECT rec/s WITH CEL rec/s CEL µs/rec",
120
+ "--------------------------------------------------------------------------",
121
+ "fixture 1,000 333,333 - 200,000 1.50",
122
+ "graph-100 2,000 250,000 - 100,000 6.00",
123
+ "graph-1000 3,000 500,000 - - -",
124
+ "NOTE Read, Project and With CEL are independent passes. CEL µs/rec is measured within With CEL; compilation is excluded."
125
+ ]);
126
+ });
127
+ it('does not print a suite summary for zero or one benchmark', () => {
128
+ expect((0, benchmark_report_1.formatBenchmarkSuiteSummary)([])).toEqual([]);
129
+ expect((0, benchmark_report_1.formatBenchmarkSuiteSummary)([example()])).toEqual([]);
130
+ });
131
+ });
132
+ describe('optional GC reporting', () => {
133
+ it('retains separate loader and integrated GC measurements and prints exact lines', () => {
134
+ const report = (0, benchmark_report_1.createBenchmarkReport)({
135
+ project: 'gc-fixture', node: '24', v8: '13', warmupRecords: 0,
136
+ loader: [
137
+ { records: 1000, totalMs: 3, celMs: 0, gc: { collections: 2, reclaimedBytes: 1048576 } },
138
+ { records: 1000, totalMs: 3, celMs: 0, gc: { collections: 4, reclaimedBytes: 2097152 } }
139
+ ],
140
+ integrated: [
141
+ { records: 1000, totalMs: 5, celMs: 1, gc: { collections: 8, reclaimedBytes: 3145728 } },
142
+ { records: 1000, totalMs: 5, celMs: 1, gc: { collections: 10, reclaimedBytes: 4194304 } }
143
+ ]
144
+ });
145
+ expect(report.passes[0].loader.gc).toEqual({ collections: 2, reclaimedBytes: 1048576, reclaimedBytesPerRecord: 1048.576 });
146
+ expect(report.passes[0].integrated.gc).toEqual({ collections: 8, reclaimedBytes: 3145728, reclaimedBytesPerRecord: 3145.728 });
147
+ expect(report.summary.loader.gcSummary).toEqual({ meanCollections: 3, meanReclaimedBytes: 1572864, meanReclaimedBytesPerRecord: 1572.864 });
148
+ expect(report.summary.integrated.gcSummary).toEqual({ meanCollections: 9, meanReclaimedBytes: 3670016, meanReclaimedBytesPerRecord: 3670.016 });
149
+ expect((0, benchmark_report_1.formatBenchmarkGcPass)(report.passes[0])).toEqual('GC PASS 1: loader 1.0 MiB reclaimed, 1,049 B/record, 2 collections; with CEL 3.0 MiB reclaimed, 3,146 B/record, 8 collections');
150
+ expect((0, benchmark_report_1.formatBenchmarkGcSummary)(report)).toEqual([
151
+ 'GC SUMMARY (mean per measured pass; V8 heap reclaimed)',
152
+ 'Loader: 1.5 MiB/pass, 1,573 B/record, 3.0 collections/pass',
153
+ 'With CEL: 3.5 MiB/pass, 3,670 B/record, 9.0 collections/pass',
154
+ 'Integrated minus loader: 2.0 MiB/pass, 2,097 B/record (approximate)',
155
+ 'NOTE GC reclaimed bytes may come from earlier passes. Independent passes may have different GC timing; their difference is not solely CEL allocation.'
156
+ ]);
157
+ expect((0, benchmark_report_1.formatBenchmarkReport)(report)).toEqual([
158
+ ...(0, benchmark_report_1.formatBenchmarkStart)({ ...report, withCel: true }),
159
+ ...report.passes.flatMap(pass => [(0, benchmark_report_1.formatBenchmarkPass)(pass), (0, benchmark_report_1.formatBenchmarkGcPass)(pass)]),
160
+ ...(0, benchmark_report_1.formatBenchmarkAverage)(report),
161
+ ...(0, benchmark_report_1.formatBenchmarkSummary)(report),
162
+ ...(0, benchmark_report_1.formatBenchmarkGcSummary)(report)
163
+ ]);
164
+ });
165
+ it('reports heap estimates for read, project and CEL and keeps legacy measurements readable', () => {
166
+ const pass = (estimated) => ({ records: 1024, totalMs: 5, celMs: 1, gc: {
167
+ collections: 1, reclaimedBytes: 4 * 1048576,
168
+ heap: { heapBeforeBytes: 8 * 1048576, heapAfterBytes: 4 * 1048576 + estimated,
169
+ heapDeltaBytes: -4 * 1048576 + estimated, netGCReclaimedBytes: 4 * 1048576,
170
+ estimatedAllocatedBytes: estimated }
171
+ } });
172
+ const base = { project: 'heap', node: '24', v8: '13', warmupRecords: 0 };
173
+ const report = (0, benchmark_report_1.createBenchmarkReport)({ ...base, loader: [pass(1048576), pass(2097152)],
174
+ projection: [pass(0), pass(0)], integrated: [pass(2097152), pass(4194304)] });
175
+ expect(report.passes[0].loader.gc?.estimatedAllocatedBytesPerRecord).toBe(1024);
176
+ expect(report.summary.loader.gcSummary?.meanEstimatedAllocatedBytesPerRecord).toBe(1536);
177
+ expect(report.summary.integrated?.gcSummary?.meanEstimatedAllocatedBytesPerRecord).toBe(3072);
178
+ expect((0, benchmark_report_1.formatBenchmarkReport)(report)).toContain('HEAP Loader: 8.0 MiB -> 5.0 MiB, delta -3.0 MiB, net GC decrease 4.0 MiB, estimated allocated 1.0 MiB, 1,024 B/record');
179
+ expect((0, benchmark_report_1.formatBenchmarkReport)(report)).toContain('Project estimated allocation: 0.0 MiB/pass, 0 B/record');
180
+ expect((0, benchmark_report_1.formatBenchmarkReport)(report)).toContain('With CEL estimated allocation: 3.0 MiB/pass, 3,072 B/record');
181
+ const legacy = (0, benchmark_report_1.createBenchmarkReport)({ ...base, project: 'legacy', loader: [{ records: 1024, totalMs: 5, celMs: 0,
182
+ gc: { collections: 0, reclaimedBytes: 0 } }] });
183
+ expect(legacy.summary.loader.gcSummary?.meanEstimatedAllocatedBytesPerRecord).toBeUndefined();
184
+ const suite = (0, benchmark_report_1.formatBenchmarkSuiteSummary)([legacy, report]);
185
+ expect(suite).toContain('ALL HEAP SUMMARY (mean estimated V8 allocated bytes per record)');
186
+ expect(suite[suite.length - 1]).toMatch(/heap\s+1,536\s+0\s+3,072$/);
187
+ });
188
+ it('rejects a mixture of measured and unmeasured GC passes', () => {
189
+ expect(() => (0, benchmark_report_1.createBenchmarkReport)({
190
+ project: 'mixed', node: '24', v8: '13', warmupRecords: 0,
191
+ loader: [
192
+ { records: 100, totalMs: 1, celMs: 0, gc: { collections: 0, reclaimedBytes: 0 } },
193
+ { records: 100, totalMs: 1, celMs: 0 }
194
+ ]
195
+ })).toThrow('Inconsistent benchmark GC measurements');
196
+ });
197
+ });
198
+ describe('cross-project GC comparison', () => {
199
+ it('reports reclaimed bytes per record for each measured workload', () => {
200
+ const make = (project, loaderBytes, integratedBytes) => (0, benchmark_report_1.createBenchmarkReport)({
201
+ project, node: '24', v8: '13', warmupRecords: 0,
202
+ loader: [{ records: 1000, totalMs: 3, celMs: 0, gc: { collections: 2, reclaimedBytes: loaderBytes } }],
203
+ integrated: [{ records: 1000, totalMs: 5, celMs: 1, gc: { collections: 4, reclaimedBytes: integratedBytes } }]
204
+ });
205
+ expect((0, benchmark_report_1.formatBenchmarkSuiteSummary)([
206
+ make('graph-100-no-map', 1048576, 2097152),
207
+ make('graph-100', 2097152, 4194304)
208
+ ])).toEqual([
209
+ '',
210
+ 'ALL SUMMARY (throughput from median elapsed time; higher rec/s is better)',
211
+ 'BENCHMARK RECORDS READ rec/s PROJECT rec/s WITH CEL rec/s CEL µs/rec',
212
+ '--------------------------------------------------------------------------------',
213
+ 'graph-100-no-map 1,000 333,333 - 200,000 1.00',
214
+ 'graph-100 1,000 333,333 - 200,000 1.00',
215
+ 'NOTE Read, Project and With CEL are independent passes. CEL µs/rec is measured within With CEL; compilation is excluded.',
216
+ '',
217
+ 'ALL GC SUMMARY (mean V8 heap bytes reclaimed per record)',
218
+ 'BENCHMARK LOADER B/rec WITH CEL B/rec DIFFERENCE B/rec',
219
+ '----------------------------------------------------------------',
220
+ 'graph-100-no-map 1,049 2,097 1,049',
221
+ 'graph-100 2,097 4,194 2,097'
222
+ ]);
223
+ });
224
+ });
225
+ describe('opt-in projection timing', () => {
226
+ it('reports optional projected scans without changing read/CEL metrics', () => {
227
+ const result = (0, benchmark_report_1.createBenchmarkReport)({ project: 'scan', node: '24', v8: '13', warmupRecords: 0,
228
+ loader: [{ records: 1000, totalMs: 2, celMs: 0 }],
229
+ projection: [{ records: 1000, totalMs: 4, celMs: 0 }],
230
+ integrated: [{ records: 1000, totalMs: 5, celMs: 1 }] });
231
+ expect(result.passes[0].projection).toEqual({
232
+ records: 1000, elapsedMs: 4, recordsPerSecond: 250000, nsPerRecord: 4000
233
+ });
234
+ expect(result.summary.projection).toEqual({
235
+ records: 1000, elapsedMs: 4, recordsPerSecond: 250000, nsPerRecord: 4000
236
+ });
237
+ const lines = (0, benchmark_report_1.formatBenchmarkReport)(result);
238
+ expect(lines.filter(line => line.startsWith('PROJECT '))).toEqual([
239
+ 'PROJECT PASS 1: 250,000 records/second (4000.0 ns/record).'
240
+ ]);
241
+ expect((0, benchmark_report_1.formatBenchmarkSummary)(result)).toEqual([
242
+ 'SUMMARY (median of 1 run; higher throughput is better)',
243
+ ' Read : 500,000 rec/s',
244
+ ' Project : 250,000 rec/s',
245
+ ' With CEL : 200,000 rec/s',
246
+ ' CEL execution : 1.00 µs/rec (range 1.00–1.00 µs/rec)'
247
+ ]);
248
+ expect(lines.filter(line => line.startsWith('PASS '))).toEqual([
249
+ 'PASS LOADER rec/s LOADER ns/rec CEL ns/rec WITH CEL rec/s TOTAL ns/rec'
250
+ ]);
251
+ expect(lines.filter(line => line.startsWith(' 1'))).toEqual([
252
+ ' 1 500,000 2000.0 1000.0 200,000 5000.0'
253
+ ]);
254
+ });
255
+ it('keeps GC for project distinct from read and CEL', () => {
256
+ const result = (0, benchmark_report_1.createBenchmarkReport)({ project: 'gc', node: '24', v8: '13', warmupRecords: 0,
257
+ loader: [{ records: 1000, totalMs: 2, celMs: 0, gc: { collections: 1, reclaimedBytes: 1048576 } }],
258
+ projection: [{ records: 1000, totalMs: 3, celMs: 0, gc: { collections: 2, reclaimedBytes: 2097152 } }] });
259
+ expect((0, benchmark_report_1.formatBenchmarkReport)(result).filter(line => line.startsWith('PROJECT GC '))).toEqual([
260
+ 'PROJECT GC PASS 1: 2.0 MiB reclaimed, 2,097 B/record, 2 collections',
261
+ 'PROJECT GC SUMMARY: 2.0 MiB/pass, 2,097 B/record, 2.0 collections/pass'
262
+ ]);
263
+ });
264
+ });
265
+ describe('stateful benchmark integrity reporting', () => {
266
+ it('retains the calculated state digest in JSON and prints it in the summary', () => {
267
+ const report = (0, benchmark_report_1.createBenchmarkReport)({ project: 'stateful', node: '24', v8: '13', warmupRecords: 0,
268
+ loader: [{ records: 20, totalMs: 4, celMs: 0 }, { records: 20, totalMs: 5, celMs: 0 }],
269
+ integrated: [
270
+ { records: 20, totalMs: 10, celMs: 6, stateDigest: '0x1234567890abcdef' },
271
+ { records: 20, totalMs: 11, celMs: 7, stateDigest: '0x1234567890abcdef' }
272
+ ] });
273
+ expect(report.passes.map(pass => pass.integrated?.stateDigest)).toEqual([
274
+ '0x1234567890abcdef', '0x1234567890abcdef'
275
+ ]);
276
+ expect((0, benchmark_report_1.formatBenchmarkSummary)(report)).toEqual([
277
+ 'SUMMARY (median of 2 runs; higher throughput is better)',
278
+ ' Read : 4,444 rec/s',
279
+ ' With CEL : 1,905 rec/s',
280
+ ' CEL execution : 325.00 µs/rec (range 300.00–350.00 µs/rec)',
281
+ ' State digest : 0x1234567890abcdef'
282
+ ]);
283
+ });
284
+ it('rejects inconsistent state calculations across measured runs', () => {
285
+ expect(() => (0, benchmark_report_1.createBenchmarkReport)({ project: 'stateful', node: '24', v8: '13', warmupRecords: 0,
286
+ loader: [{ records: 20, totalMs: 4, celMs: 0 }, { records: 20, totalMs: 5, celMs: 0 }],
287
+ integrated: [
288
+ { records: 20, totalMs: 10, celMs: 6, stateDigest: '0x01' },
289
+ { records: 20, totalMs: 11, celMs: 7, stateDigest: '0x02' }
290
+ ] })).toThrow('Stateful benchmark produced inconsistent final accumulator values across runs');
291
+ });
292
+ });
293
+ test('reference timings are reported separately without changing throughput', () => {
294
+ const load = { tables: 1, records: 5, elapsedMs: 0.25 };
295
+ const report = (0, benchmark_report_1.createBenchmarkReport)({ project: 'fixture', node: '24', v8: '13', warmupRecords: 1,
296
+ referencePreparation: [{ ...load, purpose: 'cel' }],
297
+ loader: [{ records: 10, totalMs: 2, celMs: 0 }],
298
+ integrated: [{ records: 10, totalMs: 4, celMs: 1, referenceLoad: load }] });
299
+ expect(report.passes[0]?.integrated?.elapsedMs).toBe(4);
300
+ expect(report.passes[0]?.integrated?.referenceLoad).toEqual(load);
301
+ expect((0, benchmark_report_1.formatBenchmarkReport)(report)).toContain('REFERENCE LOAD before-warmup purpose=cel tables=1 records=5 ms=0.250');
302
+ expect((0, benchmark_report_1.formatBenchmarkReport)(report)).toContain('REFERENCE LOAD pass=1 included-in-total tables=1 records=5 ms=0.250');
303
+ });
304
+ //# sourceMappingURL=benchmark.report.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark.report.spec.js","sourceRoot":"","sources":["../../src/benchmark.report.spec.ts"],"names":[],"mappings":";;AAAA,yDAA0R;AAE1R,MAAM,OAAO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CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACvD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACjE,MAAM,CAAC,IAAA,wCAAqB,EAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,sEAAsE,CAAC,CAAA;IACvH,MAAM,CAAC,IAAA,wCAAqB,EAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,qEAAqE,CAAC,CAAA;AAC1H,CAAC,CAAC,CAAA"}
@@ -0,0 +1,30 @@
1
+ import type { BenchmarkDependencies } from './benchmark.dependencies';
2
+ import { type GraphTimingReport } from './benchmark.report';
3
+ export { summariseGraphTimings } from './benchmark.report';
4
+ export { resolveBenchmarkModes, type BenchmarkMode, type BenchmarkRunOptions } from './benchmark.options';
5
+ import type { BenchmarkReport } from './benchmark.report';
6
+ import type { GarbageCollectionMeasurement } from './benchmark.gc';
7
+ import { type BenchmarkRunOptions } from './benchmark.options';
8
+ export { parseBenchmarkConfiguration, type BenchmarkConfiguration } from './benchmark.configuration';
9
+ /** Compile a projected-field path once, before scanning records. The returned
10
+ * accessor traverses each new projected row without splitting the path or
11
+ * allocating a recursive visitor closure on every record. */
12
+ export declare function compileProjectedFieldAccess(path: string): (source: unknown) => unknown;
13
+ /** Convenience API for individual accesses outside the benchmark hot path. */
14
+ export declare function accessField(source: unknown, path: string): unknown;
15
+ export interface BenchmarkPass {
16
+ readonly records: number;
17
+ readonly totalMs: number;
18
+ readonly celMs: number;
19
+ readonly loaderAndOverheadMs: number;
20
+ readonly totalNsPerRecord: number;
21
+ readonly celNsPerRecord: number;
22
+ readonly loaderAndOverheadNsPerRecord: number;
23
+ readonly gc?: GarbageCollectionMeasurement;
24
+ readonly graphTiming?: GraphTimingReport;
25
+ }
26
+ export declare function summariseBenchmarkPass(records: number, totalMs: number, celMs: number): BenchmarkPass;
27
+ /** Verify any project's file size, and optionally the complete original fixture pattern. */
28
+ export declare function verifyBenchmarkProject(dependencies: BenchmarkDependencies, directory: string): Promise<string>;
29
+ /** Every run resolves the project under the supplied directory: no bundled-name registry. */
30
+ export declare function runBenchmark(dependencies: BenchmarkDependencies, options: BenchmarkRunOptions): Promise<BenchmarkReport>;
@@ -0,0 +1,257 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseBenchmarkConfiguration = exports.resolveBenchmarkModes = exports.summariseGraphTimings = void 0;
4
+ exports.compileProjectedFieldAccess = compileProjectedFieldAccess;
5
+ exports.accessField = accessField;
6
+ exports.summariseBenchmarkPass = summariseBenchmarkPass;
7
+ exports.verifyBenchmarkProject = verifyBenchmarkProject;
8
+ exports.runBenchmark = runBenchmark;
9
+ const benchmark_report_1 = require("./benchmark.report");
10
+ var benchmark_report_2 = require("./benchmark.report");
11
+ Object.defineProperty(exports, "summariseGraphTimings", { enumerable: true, get: function () { return benchmark_report_2.summariseGraphTimings; } });
12
+ var benchmark_options_1 = require("./benchmark.options");
13
+ Object.defineProperty(exports, "resolveBenchmarkModes", { enumerable: true, get: function () { return benchmark_options_1.resolveBenchmarkModes; } });
14
+ const benchmark_format_runner_1 = require("./benchmark.format.runner");
15
+ const benchmark_execution_1 = require("./benchmark.execution");
16
+ const benchmark_options_2 = require("./benchmark.options");
17
+ const files_node_1 = require("@cobol-ts/files-node");
18
+ const node_path_1 = require("node:path");
19
+ const node_perf_hooks_1 = require("node:perf_hooks");
20
+ const cursor_loader_benchmark_1 = require("@cobol-ts/cursor-loader-benchmark");
21
+ const composition_definition_1 = require("@cobol-ts/composition-definition");
22
+ const errors_1 = require("@cobol-ts/errors");
23
+ const yaml_jsyaml_1 = require("@cobol-ts/yaml-jsyaml");
24
+ const file_display_1 = require("@cobol-ts/file-display");
25
+ const cursor_loader_cobol_node_1 = require("@cobol-ts/cursor-loader-cobol-node");
26
+ const cel_graph_runtime_1 = require("@cobol-ts/cel-graph-runtime");
27
+ const benchmark_configuration_1 = require("./benchmark.configuration");
28
+ const { readFile, stat } = files_node_1.nodeLocalFiles.promises;
29
+ var benchmark_configuration_2 = require("./benchmark.configuration");
30
+ Object.defineProperty(exports, "parseBenchmarkConfiguration", { enumerable: true, get: function () { return benchmark_configuration_2.parseBenchmarkConfiguration; } });
31
+ /** Compile a projected-field path once, before scanning records. The returned
32
+ * accessor traverses each new projected row without splitting the path or
33
+ * allocating a recursive visitor closure on every record. */
34
+ function compileProjectedFieldAccess(path) {
35
+ const parts = path.split('.');
36
+ function visit(value, index) {
37
+ if (value !== null && typeof value === 'object' && 'length' in value &&
38
+ typeof value.length === 'number') {
39
+ const array = value;
40
+ for (let i = 0; i < array.length; i++)
41
+ visit(array[i], index);
42
+ return value;
43
+ }
44
+ if (index === parts.length)
45
+ return value;
46
+ const key = parts[index];
47
+ if (value === null || typeof value !== 'object' || !(key in value))
48
+ throw new Error(`Projected field ${JSON.stringify(path)} is unavailable`);
49
+ const property = value[key];
50
+ return visit(typeof property === 'function' ? property.call(value) : property, index + 1);
51
+ }
52
+ return (source) => visit(source, 0);
53
+ }
54
+ /** Convenience API for individual accesses outside the benchmark hot path. */
55
+ function accessField(source, path) {
56
+ return compileProjectedFieldAccess(path)(source);
57
+ }
58
+ function summariseBenchmarkPass(records, totalMs, celMs) {
59
+ if (records <= 0 || totalMs <= 0 || celMs < 0 || celMs > totalMs)
60
+ throw new Error('Invalid benchmark measurement');
61
+ const remainder = totalMs - celMs;
62
+ return {
63
+ records, totalMs, celMs, loaderAndOverheadMs: remainder,
64
+ totalNsPerRecord: totalMs * 1_000_000 / records,
65
+ celNsPerRecord: celMs * 1_000_000 / records,
66
+ loaderAndOverheadNsPerRecord: remainder * 1_000_000 / records
67
+ };
68
+ }
69
+ async function readBenchmarkConfiguration(configDir) {
70
+ const source = await readFile((0, node_path_1.join)(configDir, 'benchmark.yaml'), 'utf8');
71
+ try {
72
+ return (0, benchmark_configuration_1.parseBenchmarkConfiguration)(source);
73
+ }
74
+ catch (error) {
75
+ if (!(error instanceof Error) || !/^(benchmark\.yaml: composition is required|benchmark\.yaml: invalid composition)/.test(error.message))
76
+ throw error;
77
+ const catalogue = yaml_jsyaml_1.jsYamlParser.parse(await readFile((0, node_path_1.join)(configDir, 'files.yaml'), 'utf8'));
78
+ if ('errors' in catalogue)
79
+ throw error;
80
+ const names = (0, composition_definition_1.parseCompositionNames)(catalogue.value);
81
+ if ('errors' in names)
82
+ throw error;
83
+ return (0, benchmark_configuration_1.parseBenchmarkConfiguration)(source, names.value.map(function compositionName(named) { return named.name; }));
84
+ }
85
+ }
86
+ /** Verify any project's file size, and optionally the complete original fixture pattern. */
87
+ async function verifyBenchmarkProject(dependencies, directory) {
88
+ const configDir = (0, node_path_1.join)((0, node_path_1.resolve)(directory), '.cobolts');
89
+ const config = await readBenchmarkConfiguration(configDir);
90
+ if (config.formatComparison)
91
+ return (0, benchmark_format_runner_1.verifyFormatBenchmarkProject)(dependencies, directory, config);
92
+ return dependencies.withBenchmarkSources(directory, (paths, input) => verifyConfiguredBenchmark(dependencies, paths, input, config));
93
+ }
94
+ async function verifyConfiguredBenchmark(dependencies, paths, input, config) {
95
+ const configDir = paths.directory;
96
+ if (config.file === undefined) {
97
+ const scan = await compositionScanner(dependencies, paths, config.composition, input);
98
+ const measured = await scan({ records: config.records });
99
+ return `VERIFIED composition=${config.composition} records=${measured.records}`;
100
+ }
101
+ const records = (0, benchmark_configuration_1.positiveBenchmarkInteger)(config.records, 'records');
102
+ const source = await (0, file_display_1.openConfiguredCobolFile)({ configDirectory: configDir, logicalName: config.file, input: await input(config.file) }, files_node_1.nodeTextFiles, yaml_jsyaml_1.jsYamlParser);
103
+ if ('errors' in source)
104
+ throw new Error(source.errors.join('\n'));
105
+ const size = (await stat(source.value.filename)).size;
106
+ if (source.value.framing?.kind === 'fixed') {
107
+ const length = source.value.framing.recordLength;
108
+ if (length === undefined || length <= 0)
109
+ throw new Error(`Invalid fixed-length framing: ${length}`);
110
+ if (size < records * length)
111
+ throw new Error(`Expected at least ${records * length} bytes; found ${size}`);
112
+ }
113
+ if (config.fixture)
114
+ (0, cursor_loader_benchmark_1.verifyBenchmarkPattern)(source.value.filename, config.fixture, records, await (0, composition_definition_1.hasCompositionDefinition)(yaml_jsyaml_1.jsYamlParser, configDir, files_node_1.nodeTextFiles));
115
+ return `VERIFIED records=${records} bytes=${size} fixture=${config.fixture ?? 'custom'} file=${source.value.filename}`;
116
+ }
117
+ /** Every run resolves the project under the supplied directory: no bundled-name registry. */
118
+ async function runBenchmark(dependencies, options) {
119
+ const root = (0, node_path_1.resolve)(options.directory);
120
+ (0, benchmark_options_2.validateProfilingOptions)(options);
121
+ const timingSampleEvery = (0, benchmark_options_2.resolveTimingSampleEvery)(options);
122
+ const configDir = (0, node_path_1.join)(root, '.cobolts');
123
+ const config = await readBenchmarkConfiguration(configDir);
124
+ if (config.formatComparison)
125
+ return (0, benchmark_format_runner_1.runFormatBenchmark)(dependencies, options, config, timingSampleEvery);
126
+ return dependencies.withBenchmarkSources(root, (paths, input) => runConfiguredBenchmark(dependencies, options, config, paths, input, timingSampleEvery));
127
+ }
128
+ async function runConfiguredBenchmark(dependencies, options, config, paths, input, timingSampleEvery) {
129
+ const root = paths.projectRoot, configDir = paths.directory;
130
+ const selectedComposition = options.composition ?? config.composition;
131
+ const composition = (0, errors_1.valueOrThrow)(await (0, composition_definition_1.readCompositionDefinition)(yaml_jsyaml_1.jsYamlParser, configDir, 'files.yaml', selectedComposition, files_node_1.nodeTextFiles));
132
+ if (composition.type !== 'relational')
133
+ throw new Error(`Benchmark composition ${selectedComposition} is not relational`);
134
+ const records = options.records === undefined ? config.records : (0, benchmark_configuration_1.positiveBenchmarkInteger)(options.records, 'records');
135
+ const runs = options.runs === undefined ? config.runs : (0, benchmark_configuration_1.positiveBenchmarkInteger)(options.runs, 'runs');
136
+ const source = config.file === undefined ? undefined : (0, errors_1.valueOrThrow)(await (0, file_display_1.openConfiguredCobolFile)({ configDirectory: configDir, logicalName: config.file, input: await input(config.file) }, files_node_1.nodeTextFiles, yaml_jsyaml_1.jsYamlParser));
137
+ let graph;
138
+ if (config.graph) {
139
+ const graphSource = await readFile((0, node_path_1.resolve)(configDir, config.graph), 'utf8');
140
+ graph = (0, cel_graph_runtime_1.parseAuthoringGraph)(graphSource, yaml_jsyaml_1.jsYamlParser);
141
+ if ('errors' in graph)
142
+ throw new Error(graph.errors.join('\n'));
143
+ }
144
+ let seed = {};
145
+ if (graph && 'value' in graph) {
146
+ const canonical = (0, cel_graph_runtime_1.canonicaliseCelGraph)(graph.value);
147
+ if ('errors' in canonical)
148
+ throw new Error(canonical.errors.join('\n'));
149
+ const accumulatorFile = (0, node_path_1.join)(configDir, 'accumulator.yaml');
150
+ try {
151
+ // Both CEL execution and the benchmark use the same structured or
152
+ // legacy accumulator document. Only its `initial` field is a seed map.
153
+ seed = (await dependencies.readBenchmarkAccumulator(configDir)).initial;
154
+ }
155
+ catch (error) {
156
+ throw new Error([
157
+ 'Benchmark accumulator configuration could not be loaded:',
158
+ ` File: ${accumulatorFile}`,
159
+ ' Operation: parse accumulator configuration and initial node values',
160
+ ` ${error instanceof Error ? error.message : String(error)}`
161
+ ].join('\n'));
162
+ }
163
+ const checked = (0, cel_graph_runtime_1.validateInitialAccumulator)(seed, graph.value, canonical.value);
164
+ if ('errors' in checked)
165
+ throw new Error(checked.errors.join('\n'));
166
+ }
167
+ const modes = (0, benchmark_options_2.resolveBenchmarkModes)(options.modes, graph !== undefined);
168
+ if (!source && modes.includes('project'))
169
+ throw new Error('Benchmark mode project requires a configured physical file');
170
+ (0, benchmark_options_2.validateTimingMode)(options, modes);
171
+ const profileMode = (0, benchmark_options_2.resolveProfileMode)(options, modes);
172
+ const referencePreparation = [];
173
+ // Compile once before warm-up; every pass runs a fresh scan on this executor.
174
+ const celExecutor = modes.includes('cel')
175
+ ? await dependencies.createProductionCelExecutor(root, { graph: config.graph,
176
+ composition: selectedComposition, resolveInput: input,
177
+ onReferenceLoad: load => referencePreparation.push({ ...load, purpose: 'cel' }) })
178
+ : undefined;
179
+ const cel = async ({ records: limit, timingSampleEvery }) => {
180
+ const started = node_perf_hooks_1.performance.now();
181
+ const measured = await celExecutor(limit, timingSampleEvery);
182
+ const graphTiming = measured.graphTiming ? (0, benchmark_report_1.summariseGraphTimings)(measured.graphTiming) : undefined;
183
+ const elapsed = node_perf_hooks_1.performance.now() - started;
184
+ if (source && measured.records !== limit)
185
+ throw new Error(`Composed execution processed ${measured.records} records, expected ${limit}`);
186
+ if (measured.records === 0)
187
+ throw new Error(`Benchmark composition ${selectedComposition} contains no entities`);
188
+ const { records, totalMs, celMs } = summariseBenchmarkPass(measured.records, elapsed, measured.celMs);
189
+ return { records, totalMs, celMs, ...(graphTiming ? { graphTiming } : {}) };
190
+ };
191
+ const warmup = Math.min(records ?? Infinity, config.warmup);
192
+ const header = modes.includes('cel')
193
+ ? [`WORKLOAD accumulator=indexed nodes=${graph && 'value' in graph ? Object.keys(graph.value).length : 0}`] : [];
194
+ const execution = { project: root, warmupRecords: warmup, runs, modes, profileMode,
195
+ timingSampleEvery: options.graphTiming ? timingSampleEvery : undefined, header, referencePreparation };
196
+ if (!source) {
197
+ const read = await compositionScanner(dependencies, paths, selectedComposition, input, load => referencePreparation.push({ ...load, purpose: 'loader' }));
198
+ return (0, benchmark_execution_1.executeBenchmark)(options, { ...execution, recordLimit: records }, { read, project: read, cel });
199
+ }
200
+ // Physical-only diagnostics bypass composition; prepare configured reference data once
201
+ // outside their measured scans so a read-only benchmark still validates its reference files.
202
+ if (!celExecutor && composition.composition.referenceData !== undefined) {
203
+ const prepared = await dependencies.prepareConfiguredComposition(paths, composition, input);
204
+ if (prepared.referenceLoad)
205
+ referencePreparation.push({ ...prepared.referenceLoad, purpose: 'loader' });
206
+ }
207
+ // Compile diagnostic field traversal only when the caller explicitly requests it.
208
+ const projectAccessors = modes.includes('project') ? config.fields.map(compileProjectedFieldAccess) : undefined;
209
+ // The read/project diagnostics use the physical source. CEL runs through
210
+ // the exact composed executor used by the public CLI.
211
+ const fileOptions = {
212
+ filename: source.filename, copybook: source.copybook, projection: source.runtimeProjection,
213
+ ...(config.encoding ? { decodeOptions: { encoding: config.encoding } } : {}),
214
+ ...(source.framing ? { framing: source.framing } : {})
215
+ };
216
+ const physical = (accessors) => async ({ records: limit }) => {
217
+ const count = (0, benchmark_configuration_1.positiveBenchmarkInteger)(limit, 'records');
218
+ let seen = 0;
219
+ const started = node_perf_hooks_1.performance.now();
220
+ const onRecord = accessors ? (projected) => {
221
+ for (const access of accessors)
222
+ access(projected);
223
+ return ++seen < count;
224
+ } : () => ++seen < count;
225
+ await (0, cursor_loader_cobol_node_1.scanCobolFile)(fileOptions, onRecord);
226
+ const elapsed = node_perf_hooks_1.performance.now() - started;
227
+ if (seen !== limit)
228
+ throw new Error(`Benchmark ended early: ${seen}/${limit} records`);
229
+ const { records, totalMs, celMs } = summariseBenchmarkPass(seen, elapsed, 0);
230
+ return { records, totalMs, celMs };
231
+ };
232
+ return (0, benchmark_execution_1.executeBenchmark)(options, { ...execution, records: (0, benchmark_configuration_1.positiveBenchmarkInteger)(records, 'records') }, {
233
+ read: physical(),
234
+ project: physical(projectAccessors),
235
+ cel
236
+ });
237
+ }
238
+ /** Measure the same entity stream used by production CEL, without evaluating the graph. */
239
+ async function compositionScanner(dependencies, paths, name, input, onReferenceLoad) {
240
+ const definition = (0, errors_1.valueOrThrow)(await (0, composition_definition_1.readCompositionDefinition)(yaml_jsyaml_1.jsYamlParser, paths.directory, 'files.yaml', name, files_node_1.nodeTextFiles));
241
+ if (definition.type !== 'relational')
242
+ throw new Error(`Benchmark composition ${name} is not relational`);
243
+ const prepared = await dependencies.prepareConfiguredComposition(paths, definition, input);
244
+ if (prepared.referenceLoad)
245
+ onReferenceLoad?.(prepared.referenceLoad);
246
+ return async ({ records: limit }) => {
247
+ let seen = 0;
248
+ const started = node_perf_hooks_1.performance.now();
249
+ const maximum = limit ?? Infinity;
250
+ await prepared.composed.scan(() => ++seen < maximum);
251
+ const totalMs = node_perf_hooks_1.performance.now() - started;
252
+ if (seen === 0)
253
+ throw new Error(`Benchmark composition ${name} contains no entities`);
254
+ return { records: seen, totalMs, celMs: 0 };
255
+ };
256
+ }
257
+ //# sourceMappingURL=benchmark.runner.js.map