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

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,6 @@
1
+ /** Configure existing data; never generate or modify input files. */
2
+ export declare function initProjectBenchmark(directory: string, options: {
3
+ composition?: string;
4
+ records?: string;
5
+ force?: boolean;
6
+ }): Promise<string>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initProjectBenchmark = initProjectBenchmark;
4
+ const files_node_1 = require("@cobol-ts/files-node");
5
+ const yaml_jsyaml_1 = require("@cobol-ts/yaml-jsyaml");
6
+ const files_node_2 = require("@cobol-ts/files-node");
7
+ const node_path_1 = require("node:path");
8
+ const composition_definition_1 = require("@cobol-ts/composition-definition");
9
+ const errors_1 = require("@cobol-ts/errors");
10
+ const benchmark_runner_1 = require("./benchmark.runner");
11
+ const { writeFile } = files_node_2.nodeLocalFiles.promises;
12
+ /** Configure existing data; never generate or modify input files. */
13
+ async function initProjectBenchmark(directory, options) {
14
+ if (options.records !== undefined)
15
+ throw new Error('--records is only valid when generating bundled benchmarks; use benchmark run -n to limit existing data');
16
+ const names = (0, errors_1.valueOrThrow)(await (0, composition_definition_1.readCompositionNames)(yaml_jsyaml_1.jsYamlParser, directory, 'files.yaml', files_node_1.nodeTextFiles.read))
17
+ .filter(named => named.type === 'relational').map(named => named.name);
18
+ const composition = options.composition ?? (names.length === 1 ? names[0] : undefined);
19
+ if (!composition || !names.includes(composition))
20
+ throw new Error(`Select a relational composition with --composition. Available: ${names.join(', ') || '(none)'}`);
21
+ const source = `version: 1\ncomposition: ${JSON.stringify(composition)}\nwarmup: 1000\nruns: 3\ngraph: graph.yaml\n`;
22
+ (0, benchmark_runner_1.parseBenchmarkConfiguration)(source);
23
+ const filename = (0, node_path_1.join)(directory, 'benchmark.yaml');
24
+ try {
25
+ await writeFile(filename, source, { flag: options.force ? 'w' : 'wx' });
26
+ }
27
+ catch (error) {
28
+ if (error && typeof error === 'object' && 'code' in error && error.code === 'EEXIST')
29
+ throw new Error(`Benchmark configuration already exists: ${filename}. Use --force to replace it.`);
30
+ throw error;
31
+ }
32
+ return filename;
33
+ }
34
+ //# sourceMappingURL=benchmark.init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark.init.js","sourceRoot":"","sources":["../../src/benchmark.init.ts"],"names":[],"mappings":";;AAWA,oDAoBC;AA/BD,qDAAkD;AAClD,uDAAkD;AAClD,qDAAmD;AACnD,yCAA8B;AAC9B,6EAAqE;AACrE,6CAA6C;AAC7C,yDAA8D;AAE9D,MAAM,EAAC,SAAS,EAAC,GAAG,2BAAc,CAAC,QAAQ,CAAA;AAE3C,qEAAqE;AAC9D,KAAK,UAAU,oBAAoB,CAAC,SAAiB,EAAE,OAE7D;IACG,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS;QAC7B,MAAM,IAAI,KAAK,CAAC,yGAAyG,CAAC,CAAA;IAC9H,MAAM,KAAK,GAAG,IAAA,qBAAY,EAAC,MAAM,IAAA,6CAAoB,EAAC,0BAAY,EAAC,SAAS,EAAC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measureGC } from './benchmark.gc';
2
+ import { captureBenchmarkProfile, type BenchmarkProfileKind } from './benchmark.profile';
3
+ import type { TimedPass } from './benchmark.report';
4
+ export interface BenchmarkProfile {
5
+ readonly kind: BenchmarkProfileKind;
6
+ readonly filename: string;
7
+ }
8
+ export interface MeasurementServices {
9
+ readonly gc: typeof measureGC;
10
+ readonly profile: typeof captureBenchmarkProfile;
11
+ }
12
+ type Operation<T> = () => Promise<T>;
13
+ /** Profile surrounds GC collection, which surrounds the workload's own clock. */
14
+ export declare function measureBenchmarkPass<T extends TimedPass>(operation: Operation<T>, collectGC?: boolean, profile?: BenchmarkProfile, services?: MeasurementServices): Promise<T>;
15
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.measureBenchmarkPass = measureBenchmarkPass;
4
+ const benchmark_gc_1 = require("./benchmark.gc");
5
+ const benchmark_profile_1 = require("./benchmark.profile");
6
+ const nodeMeasurementServices = { gc: benchmark_gc_1.measureGC, profile: benchmark_profile_1.captureBenchmarkProfile };
7
+ /** Profile surrounds GC collection, which surrounds the workload's own clock. */
8
+ function measureBenchmarkPass(operation, collectGC = false, profile, services = nodeMeasurementServices) {
9
+ const measured = collectGC ? async () => {
10
+ const result = await services.gc(operation);
11
+ return { ...result.value, gc: result.gc };
12
+ } : operation;
13
+ return profile ? services.profile(profile.kind, profile.filename, measured) : measured();
14
+ }
15
+ //# sourceMappingURL=benchmark.measurement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark.measurement.js","sourceRoot":"","sources":["../../src/benchmark.measurement.ts"],"names":[],"mappings":";;AAmBA,oDASC;AA5BD,iDAAwC;AACxC,2DAAsF;AAatF,MAAM,uBAAuB,GAAwB,EAAC,EAAE,EAAE,wBAAS,EAAE,OAAO,EAAE,2CAAuB,EAAC,CAAA;AAItG,iFAAiF;AACjF,SAAgB,oBAAoB,CAChC,SAAuB,EAAE,SAAS,GAAG,KAAK,EAAE,OAA0B,EACtE,WAAgC,uBAAuB;IAEvD,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;QACpC,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,EAAE,CAAC,SAAS,CAAC,CAAA;QAC3C,OAAO,EAAC,GAAG,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAC,CAAA;IAC3C,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACb,OAAO,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;AAC5F,CAAC"}
@@ -0,0 +1,29 @@
1
+ export type BenchmarkMode = 'read' | 'project' | 'cel';
2
+ /** Read is the reference measurement. Project is opt-in, since it forces
3
+ * otherwise-lazy projected fields to be visited. */
4
+ export declare function resolveBenchmarkModes(requested: string | undefined, graphAvailable: boolean): readonly BenchmarkMode[];
5
+ export interface BenchmarkRunOptions {
6
+ readonly directory: string;
7
+ readonly composition?: string;
8
+ readonly records?: number;
9
+ readonly runs?: number;
10
+ readonly log: (message: string) => void;
11
+ readonly json?: boolean;
12
+ readonly gc?: boolean;
13
+ /** Opt-in sampling of accumulator reset/copies and graph generations. */
14
+ readonly graphTiming?: boolean;
15
+ /** Sample every Nth entity (default 100). */
16
+ readonly timingSampleEvery?: number;
17
+ /** Comma-separated modes; defaults to read,cel for projects with a graph. */
18
+ readonly modes?: string;
19
+ /** Profile the first measured pass of the selected mode (default: cel). */
20
+ readonly cpuProfile?: boolean;
21
+ readonly allocationProfile?: boolean;
22
+ /** Which pass to sample; requires one of the profile flags. */
23
+ readonly profileMode?: BenchmarkMode;
24
+ }
25
+ /** Validate CLI-specific options before constructing a benchmark definition. */
26
+ export declare function validateProfilingOptions(options: BenchmarkRunOptions): void;
27
+ export declare function resolveTimingSampleEvery(options: BenchmarkRunOptions): number;
28
+ export declare function validateTimingMode(options: BenchmarkRunOptions, modes: readonly BenchmarkMode[]): void;
29
+ export declare function resolveProfileMode(options: BenchmarkRunOptions, modes: readonly BenchmarkMode[]): BenchmarkMode;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveBenchmarkModes = resolveBenchmarkModes;
4
+ exports.validateProfilingOptions = validateProfilingOptions;
5
+ exports.resolveTimingSampleEvery = resolveTimingSampleEvery;
6
+ exports.validateTimingMode = validateTimingMode;
7
+ exports.resolveProfileMode = resolveProfileMode;
8
+ /** Read is the reference measurement. Project is opt-in, since it forces
9
+ * otherwise-lazy projected fields to be visited. */
10
+ function resolveBenchmarkModes(requested, graphAvailable) {
11
+ if (requested === undefined)
12
+ return graphAvailable ? ['read', 'cel'] : ['read'];
13
+ // PowerShell wrappers may turn an unquoted comma-list into a space-separated
14
+ // argument. Accept either representation; preserve the supplied value in
15
+ // diagnostics so command-line transformations are visible.
16
+ const names = requested.trim().split(/[\s,]+/);
17
+ if (names.some(name => name !== 'read' && name !== 'project' && name !== 'cel') ||
18
+ new Set(names).size !== names.length || !names.includes('read'))
19
+ throw new Error(`Invalid benchmark modes ${JSON.stringify(requested)}: expected a unique selection of read,project,cel including read`);
20
+ if (names.includes('cel') && !graphAvailable)
21
+ throw new Error('Benchmark mode cel requires a configured CEL graph');
22
+ return names;
23
+ }
24
+ /** Validate CLI-specific options before constructing a benchmark definition. */
25
+ function validateProfilingOptions(options) {
26
+ if (options.cpuProfile && options.allocationProfile)
27
+ throw new Error('Choose either --cpu-profile or --allocation-profile, not both');
28
+ if (options.graphTiming && (options.cpuProfile || options.allocationProfile))
29
+ throw new Error('Graph timing and sampling profiles must be measured separately');
30
+ }
31
+ function resolveTimingSampleEvery(options) {
32
+ if (options.timingSampleEvery !== undefined && !options.graphTiming)
33
+ throw new Error('--timing-sample-every requires --graph-timing');
34
+ const interval = options.timingSampleEvery ?? 100;
35
+ if (!Number.isSafeInteger(interval) || interval < 1)
36
+ throw new Error('--timing-sample-every must be a positive safe integer');
37
+ return interval;
38
+ }
39
+ function validateTimingMode(options, modes) {
40
+ if (options.graphTiming && !modes.includes('cel'))
41
+ throw new Error('--graph-timing requires CEL benchmark mode');
42
+ }
43
+ function resolveProfileMode(options, modes) {
44
+ const requested = !!(options.cpuProfile || options.allocationProfile);
45
+ const explicit = options.profileMode !== undefined;
46
+ if (explicit && !requested)
47
+ throw new Error('--profile-mode requires --cpu-profile or --allocation-profile');
48
+ const mode = options.profileMode ?? 'cel';
49
+ if (requested && !modes.includes(mode))
50
+ throw new Error(`Profile mode ${JSON.stringify(mode)} is not enabled; selected modes: ${modes.join(',')}`);
51
+ return mode;
52
+ }
53
+ //# sourceMappingURL=benchmark.options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark.options.js","sourceRoot":"","sources":["../../src/benchmark.options.ts"],"names":[],"mappings":";;AAIA,sDAYC;AAwBD,4DAIC;AAED,4DAMC;AAED,gDAEC;AAED,gDAOC;AA/DD;oDACoD;AACpD,SAAgB,qBAAqB,CAAC,SAA6B,EAAE,cAAuB;IACxF,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IAC/E,6EAA6E;IAC7E,yEAAyE;IACzE,2DAA2D;IAC3D,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAC9C,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,KAAK,CAAC;QAC3E,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,Q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,SAAS,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAA;IACrE,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,KAAK,SAAS,CAAA;IAClD,IAAI,QAAQ,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAA;IAC5G,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,IAAI,KAAK,CAAA;IACzC,IAAI,SAAS,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,oCAAoC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAClJ,OAAO,IAAI,CAAA;AACf,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const PERIODIC_BENCHMARK: "graph-1000-periodic";
2
+ /** Seed completed histories rather than timing empty windows and fresh daily counters.
3
+ * This produces one sorted historical accumulator for each generated master entity.
4
+ */
5
+ export declare function generatePeriodicBenchmarkProject(base: string, records: number, force?: boolean): Promise<string>;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PERIODIC_BENCHMARK = void 0;
4
+ exports.generatePeriodicBenchmarkProject = generatePeriodicBenchmarkProject;
5
+ const files_node_1 = require("@cobol-ts/files-node");
6
+ const node_path_1 = require("node:path");
7
+ const cursor_loader_benchmark_1 = require("@cobol-ts/cursor-loader-benchmark");
8
+ const cel_graph_runtime_1 = require("@cobol-ts/cel-graph-runtime");
9
+ const cursor_loader_indexed_graph_state_1 = require("@cobol-ts/cursor-loader-indexed-graph-state");
10
+ const cursor_loader_indexed_graph_state_node_1 = require("@cobol-ts/cursor-loader-indexed-graph-state-node");
11
+ const ring_buffer_1 = require("@cobol-ts/ring-buffer");
12
+ const yaml_jsyaml_1 = require("@cobol-ts/yaml-jsyaml");
13
+ const { readFile, writeFile } = files_node_1.nodeLocalFiles.promises;
14
+ exports.PERIODIC_BENCHMARK = 'graph-1000-periodic';
15
+ /** Seed completed histories rather than timing empty windows and fresh daily counters.
16
+ * This produces one sorted historical accumulator for each generated master entity.
17
+ */
18
+ async function generatePeriodicBenchmarkProject(base, records, force = false) {
19
+ if (!Number.isSafeInteger(records) || records < 1)
20
+ throw new RangeError('records must be positive');
21
+ const destination = (0, node_path_1.resolve)(base, exports.PERIODIC_BENCHMARK);
22
+ await (0, cursor_loader_benchmark_1.generateBenchmarkProject)(base, exports.PERIODIC_BENCHMARK, records, force);
23
+ const config = (0, node_path_1.join)(destination, '.cobolts');
24
+ const source = await readFile((0, node_path_1.join)(config, 'graph.yaml'), 'utf8');
25
+ const graph = (0, cel_graph_runtime_1.parseAuthoringGraph)(source, yaml_jsyaml_1.jsYamlParser);
26
+ if ('errors' in graph)
27
+ throw new Error(graph.errors.join('\n'));
28
+ const canonical = (0, cel_graph_runtime_1.canonicaliseCelGraph)(graph.value);
29
+ if ('errors' in canonical)
30
+ throw new Error(canonical.errors.join('\n'));
31
+ const planned = (0, cel_graph_runtime_1.planCanonicalCelGraph)(canonical.value);
32
+ if ('errors' in planned)
33
+ throw new Error(planned.errors.join('\n'));
34
+ const nodes = planned.value.generations.flat();
35
+ if (nodes.length !== 1000)
36
+ throw new Error(`Expected 1000 benchmark nodes, received ${nodes.length}`);
37
+ const schema = (0, cursor_loader_indexed_graph_state_1.indexedGraphSchemaFromValueTypes)(nodes.map(node => ({ name: node.metadata.name, valueType: node.valueType })));
38
+ await writeFile((0, node_path_1.join)(config, 'accumulator.yaml'), 'file: ../data/previous-state.igs\noptional: false\nremoved: reject\ncustomerId:\n field: recordId\n type: number\ninitial: {}\n');
39
+ // Fixed warm-up, without re-reading every record in a large historical fixture.
40
+ const original = await readFile((0, node_path_1.join)(config, 'benchmark.yaml'), 'utf8');
41
+ await writeFile((0, node_path_1.join)(config, 'benchmark.yaml'), original.replace('warmup: 100000', 'warmup: 1000'));
42
+ function* previous() {
43
+ for (let customer = 1; customer <= records; customer++) {
44
+ const state = (0, cursor_loader_indexed_graph_state_1.createIndexedGraphRecord)(schema.nodes.length);
45
+ state.customerId = BigInt(customer);
46
+ for (let i = 0; i < schema.nodes.length; i++) {
47
+ const field = schema.nodes[i];
48
+ if (field.type === 'rolling-window') {
49
+ const history = (0, ring_buffer_1.createRingBuffer)(6);
50
+ for (let month = 1; month <= 7; month++)
51
+ (0, ring_buffer_1.push)(history, month);
52
+ state.values[i] = history;
53
+ }
54
+ else if (/^node00\d\d$/.test(field.name)) {
55
+ // Completed daily counter carried over from the preceding daily run.
56
+ state.values[i] = 30 + (customer % 5);
57
+ }
58
+ else if (/^node02\d\d$/.test(field.name)) {
59
+ // 2+3+4+5+6+7, the six active months (1 has expired).
60
+ state.values[i] = 27;
61
+ }
62
+ else
63
+ state.values[i] = 0;
64
+ }
65
+ yield state;
66
+ }
67
+ }
68
+ await (0, cursor_loader_indexed_graph_state_node_1.writeIndexedGraphStateFile)((0, node_path_1.join)(destination, 'data', 'previous-state.igs'), schema, previous());
69
+ return destination;
70
+ }
71
+ //# sourceMappingURL=benchmark.periodic.fixture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark.periodic.fixture.js","sourceRoot":"","sources":["../../src/benchmark.periodic.fixture.ts"],"names":[],"mappings":";;;AAgBA,4EA2CC;AA3DD,qDAAmD;AACnD,yCAAuC;AACvC,+EAA0E;AAC1E,mEAA4G;AAC5G,mGAAsH;AACtH,6GAA2F;AAC3F,uDAA4D;AAC5D,uDAAkD;AAElD,MAAM,EAAC,QAAQ,EAAE,SAAS,EAAC,GAAG,2BAAc,CAAC,QAAQ,CAAA;AAExC,QAAA,kBAAkB,GAAG,qBAA8B,CAAA;AAEhE;;GAEG;AACI,KAAK,UAAU,gCAAgC,CAAC,IAAY,EAAE,OAAe,EAAE,KAAK,GAAG,KAAK;IAC/F,IAAI,CAAC,MAAM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EAAC,KAAK,EAAE;wBAAE,IAAA,kBAAI,EAAC,OAAO,EAAC,KAAK,CAAC,CAAA;oBACtD,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAC,OAAO,CAAA;gBAC3B,CAAC;qBAAM,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;oBACzC,qEAAqE;oBACrE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAC,EAAE,GAAC,CAAC,QAAQ,GAAC,CAAC,CAAC,CAAA;gBACnC,CAAC;qBAAM,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;oBACzC,sDAAsD;oBACtD,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAC,EAAE,CAAA;gBACtB,CAAC;;oBAAM,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAC,CAAC,CAAA;YAC5B,CAAC;YACD,MAAM,KAAK,CAAA;QACf,CAAC;IACL,CAAC;IACD,MAAM,IAAA,mEAA0B,EAAC,IAAA,gBAAI,EAAC,WAAW,EAAC,MAAM,EAAC,oBAAoB,CAAC,EAAC,MAAM,EAAC,QAAQ,EAAE,CAAC,CAAA;IACjG,OAAO,WAAW,CAAA;AACtB,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const promises_1 = require("node:fs/promises");
4
+ const node_os_1 = require("node:os");
5
+ const node_path_1 = require("node:path");
6
+ const cursor_loader_benchmark_1 = require("@cobol-ts/cursor-loader-benchmark");
7
+ const cel_graph_runtime_1 = require("@cobol-ts/cel-graph-runtime");
8
+ const yaml_jsyaml_1 = require("@cobol-ts/yaml-jsyaml");
9
+ const cursor_loader_indexed_graph_state_node_1 = require("@cobol-ts/cursor-loader-indexed-graph-state-node");
10
+ const cursor_loader_indexed_graph_state_1 = require("@cobol-ts/cursor-loader-indexed-graph-state");
11
+ const ring_buffer_1 = require("@cobol-ts/ring-buffer");
12
+ const benchmark_periodic_fixture_1 = require("./benchmark.periodic.fixture");
13
+ const cursor_loader_source_node_1 = require("@cobol-ts/cursor-loader-source-node");
14
+ it('generates exactly 100 daily scalars, 100 six-month windows, 100 sums and 700 other nodes', () => {
15
+ const parsed = (0, cel_graph_runtime_1.parseAuthoringGraph)((0, cursor_loader_benchmark_1.periodicGraphYaml)(), yaml_jsyaml_1.jsYamlParser);
16
+ if ('errors' in parsed)
17
+ throw new Error(parsed.errors.join('\n'));
18
+ const nodes = Object.entries(parsed.value);
19
+ expect(nodes.map(([name]) => name)).toEqual(Array.from({ length: 1000 }, (_, i) => `node${String(i).padStart(4, '0')}`));
20
+ expect(nodes.slice(0, 100).map(([name, node]) => {
21
+ if (node.type !== 'cel')
22
+ throw new Error(`Expected CEL node ${name}`);
23
+ return [node.metadata.periodicity, node.metadata.resetOn];
24
+ })).toEqual(Array.from({ length: 100 }, () => ['daily', 'monthly']));
25
+ expect(nodes.slice(100, 200).map(([name, node]) => {
26
+ if (node.type !== 'cel')
27
+ throw new Error(`Expected CEL node ${name}`);
28
+ return node.metadata.rollingWindow;
29
+ })).toEqual(Array.from({ length: 100 }, () => ({ periodicity: 'monthly', size: 6 })));
30
+ expect(nodes.slice(200, 300).map(([, node], i) => node.cel))
31
+ .toEqual(Array.from({ length: 100 }, (_, i) => `now.node${String(i + 100).padStart(4, '0')}.sum()`));
32
+ expect(nodes.slice(300, 370).map(([, node], i) => node.cel))
33
+ .toEqual(Array.from({ length: 70 }, (_, i) => `now.node${String(i + 200).padStart(4, '0')} + 1`));
34
+ expect(nodes.slice(370).map(([, node]) => node.cel))
35
+ .toEqual(Array.from({ length: 630 }, () => 'input.itemCount'));
36
+ const canonical = (0, cel_graph_runtime_1.canonicaliseCelGraph)(parsed.value);
37
+ if ('errors' in canonical)
38
+ throw new Error(canonical.errors.join('\n'));
39
+ expect(canonical.value.filter(n => n.valueType.kind === 'rolling-window').length).toBe(100);
40
+ expect(canonical.value.every(node => node.valueType.kind === 'rolling-window'
41
+ ? node.valueType.element.javascriptType === 'number'
42
+ : node.valueType.javascriptType === 'number')).toBe(true);
43
+ });
44
+ it('produces indexed historical records with six active months and the seventh expired', async () => {
45
+ const base = await (0, promises_1.mkdtemp)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'cobolts-periodic-'));
46
+ try {
47
+ const folder = await (0, benchmark_periodic_fixture_1.generatePeriodicBenchmarkProject)(base, 2);
48
+ const graph = await (0, promises_1.readFile)((0, node_path_1.join)(folder, '.cobolts', 'graph.yaml'), 'utf8');
49
+ expect(graph).toBe((0, cursor_loader_benchmark_1.periodicGraphYaml)().replace(/\binput\./g, 'input.records.'));
50
+ const configured = await (0, promises_1.readFile)((0, node_path_1.join)(folder, '.cobolts', 'files.yaml'), 'utf8');
51
+ expect(configured).toContain(' celIntegerRepresentation: number\n');
52
+ const input = await (0, cursor_loader_source_node_1.prepareConfiguredFileSource)({ configDirectory: (0, node_path_1.join)(folder, '.cobolts'), logicalName: 'records' });
53
+ const countAccess = input.access.compileScalar(['itemCount']);
54
+ if ('errors' in countAccess)
55
+ throw new Error(countAccess.errors.join('\n'));
56
+ expect(countAccess.value.integerStorage).toBe('number');
57
+ const accumulator = await (0, promises_1.readFile)((0, node_path_1.join)(folder, '.cobolts', 'accumulator.yaml'), 'utf8');
58
+ expect(accumulator).toBe('file: ../data/previous-state.igs\noptional: false\nremoved: reject\ncustomerId:\n field: recordId\n type: number\ninitial: {}\n');
59
+ const filename = (0, node_path_1.join)(folder, 'data', 'previous-state.igs');
60
+ expect((await (0, promises_1.stat)(filename)).size > 0).toBe(true);
61
+ const schema = await (0, cursor_loader_indexed_graph_state_node_1.readIndexedGraphStateFileSchema)(filename);
62
+ expect(schema.nodes.length).toBe(1000);
63
+ expect(schema.nodes.filter(node => node.type === 'rolling-window').length).toBe(100);
64
+ // Persisted descriptors describe physical int64 storage, not JS representation.
65
+ // Explicitly project the historical record into the benchmark's number-backed schema.
66
+ const parsed = (0, cel_graph_runtime_1.parseAuthoringGraph)(graph, yaml_jsyaml_1.jsYamlParser);
67
+ if ('errors' in parsed)
68
+ throw new Error(parsed.errors.join('\n'));
69
+ const canonical = (0, cel_graph_runtime_1.canonicaliseCelGraph)(parsed.value);
70
+ if ('errors' in canonical)
71
+ throw new Error(canonical.errors.join('\n'));
72
+ const planned = (0, cel_graph_runtime_1.planCanonicalCelGraph)(canonical.value);
73
+ if ('errors' in planned)
74
+ throw new Error(planned.errors.join('\n'));
75
+ const expectedSchema = (0, cursor_loader_indexed_graph_state_1.indexedGraphSchemaFromValueTypes)(planned.value.generations.flat()
76
+ .map(node => ({ name: node.metadata.name, valueType: node.valueType })));
77
+ expect(expectedSchema.nodes.every(node => node.javascriptType === 'number')).toBe(true);
78
+ let seen = 0;
79
+ for await (const state of (0, cursor_loader_indexed_graph_state_node_1.readIndexedGraphStateFile)(filename, { activeSchema: expectedSchema })) {
80
+ const record = state.representation;
81
+ seen++;
82
+ expect(record.customerId).toBe(BigInt(seen));
83
+ const byName = new Map(schema.nodes.map((node, i) => [node.name, i]));
84
+ expect(record.values[byName.get('node0000')]).toBe(30 + (seen % 5));
85
+ const history = record.values[byName.get('node0100')];
86
+ expect([history.size, (0, ring_buffer_1.length)(history), ...Array.from({ length: 6 }, (_, i) => (0, ring_buffer_1.get)(history, i)), (0, ring_buffer_1.expired)(history)])
87
+ .toEqual([6, 6, 2, 3, 4, 5, 6, 7, 1]);
88
+ expect(record.values[byName.get('node0200')]).toBe(27);
89
+ state.close();
90
+ }
91
+ expect(seen).toBe(2);
92
+ }
93
+ finally {
94
+ await (0, promises_1.rm)(base, { recursive: true, force: true });
95
+ }
96
+ });
97
+ //# sourceMappingURL=benchmark.periodic.fixture.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark.periodic.fixture.spec.js","sourceRoot":"","sources":["../../src/benchmark.periodic.fixture.spec.ts"],"names":[],"mappings":";;AAAA,+CAA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AC,IAAI,EAAC,IAAA,oBAAM,EAAC,OAAO,CAAC,EAAC,GAAG,KAAK,CAAC,IAAI,CAAC,EAAC,MAAM,EAAC,CAAC,EAAC,EAAC,CAAC,CAAC,EAAC,CAAC,EAAC,EAAE,CAAA,IAAA,iBAAG,EAAC,OAAO,EAAC,CAAC,CAAC,CAAC,EAAC,IAAA,qBAAO,EAAC,OAAO,CAAC,CAAC,CAAC;iBAClG,OAAO,CAAC,CAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAA;YACjC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACvD,KAAK,CAAC,KAAK,EAAE,CAAA;QACjB,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACxB,CAAC;YAAO,CAAC;QAAA,MAAM,IAAA,aAAE,EAAC,IAAI,EAAC,EAAC,SAAS,EAAC,IAAI,EAAC,KAAK,EAAC,IAAI,EAAC,CAAC,CAAA;IAAA,CAAC;AACxD,CAAC,CAAC,CAAA"}
@@ -0,0 +1,9 @@
1
+ export type BenchmarkProfileKind = 'cpu' | 'allocation';
2
+ export declare function benchmarkProfileFilename(project: string, mode: 'read' | 'project' | 'cel', kind: BenchmarkProfileKind): string;
3
+ /**
4
+ * Sample one selected measured pass, after compilation and warm-up.
5
+ * CPU profiles can be opened in Chrome DevTools Performance panel; allocation
6
+ * sampling profiles can be opened in the Memory panel. These are diagnostic
7
+ * runs: their timings should not be used for performance comparisons.
8
+ */
9
+ export declare function captureBenchmarkProfile<T>(kind: BenchmarkProfileKind, filename: string, action: () => Promise<T>): Promise<T>;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.benchmarkProfileFilename = benchmarkProfileFilename;
4
+ exports.captureBenchmarkProfile = captureBenchmarkProfile;
5
+ const node_inspector_1 = require("node:inspector");
6
+ const files_node_1 = require("@cobol-ts/files-node");
7
+ const node_path_1 = require("node:path");
8
+ const { mkdir, writeFile } = files_node_1.nodeLocalFiles.promises;
9
+ function benchmarkProfileFilename(project, mode, kind) {
10
+ const extension = kind === 'cpu' ? 'cpuprofile' : 'heapprofile';
11
+ return (0, node_path_1.join)(project, `${(0, node_path_1.basename)(project)}.${mode}.${extension}`);
12
+ }
13
+ /** Inspector messages used for profiling without Node startup flags or external packages. */
14
+ function post(session, method, params = {}) {
15
+ return new Promise((resolve, reject) => {
16
+ session.post(method, params, (error, response) => {
17
+ if (error)
18
+ reject(error);
19
+ else
20
+ resolve(response);
21
+ });
22
+ });
23
+ }
24
+ /**
25
+ * Sample one selected measured pass, after compilation and warm-up.
26
+ * CPU profiles can be opened in Chrome DevTools Performance panel; allocation
27
+ * sampling profiles can be opened in the Memory panel. These are diagnostic
28
+ * runs: their timings should not be used for performance comparisons.
29
+ */
30
+ async function captureBenchmarkProfile(kind, filename, action) {
31
+ const session = new node_inspector_1.Session();
32
+ session.connect();
33
+ const cpu = kind === 'cpu';
34
+ const stop = cpu ? 'Profiler.stop' : 'HeapProfiler.stopSampling';
35
+ let active = false;
36
+ try {
37
+ if (cpu) {
38
+ await post(session, 'Profiler.enable');
39
+ await post(session, 'Profiler.start');
40
+ }
41
+ else {
42
+ await post(session, 'HeapProfiler.enable');
43
+ await post(session, 'HeapProfiler.startSampling', {
44
+ samplingInterval: 32768,
45
+ // Include short-lived objects, not just those surviving GC.
46
+ includeObjectsCollectedByMinorGC: true,
47
+ includeObjectsCollectedByMajorGC: true
48
+ });
49
+ }
50
+ active = true;
51
+ const value = await action();
52
+ const result = await post(session, stop);
53
+ active = false;
54
+ await mkdir((0, node_path_1.dirname)(filename), { recursive: true });
55
+ await writeFile(filename, JSON.stringify(result.profile));
56
+ return value;
57
+ }
58
+ finally {
59
+ if (active) {
60
+ try {
61
+ await post(session, stop);
62
+ }
63
+ catch { /* Preserve the original execution error. */ }
64
+ }
65
+ session.disconnect();
66
+ }
67
+ }
68
+ //# sourceMappingURL=benchmark.profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark.profile.js","sourceRoot":"","sources":["../../src/benchmark.profile.ts"],"names":[],"mappings":";;AAQA,4DAGC;AAkBD,0DAoCC;AAjED,mDAAsC;AACtC,qDAAmD;AACnD,yCAAiD;AAEjD,MAAM,EAAC,KAAK,EAAE,SAAS,EAAC,GAAG,2BAAc,CAAC,QAAQ,CAAA;AAIlD,SAAgB,wBAAwB,CAAC,OAAe,EAAE,IAAgC,EAAE,IAA0B;IAClH,MAAM,SAAS,GAAG,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAA;IAC/D,OAAO,IAAA,gBAAI,EAAC,OAAO,EAAE,GAAG,IAAA,oBAAQ,EAAC,OAAO,CAAC,IAAI,IAAI,IAAI,SAAS,EAAE,CAAC,CAAA;AACrE,CAAC;AAED,6FAA6F;AAC7F,SAAS,IAAI,CAAI,OAAgB,EAAE,MAAc,EAAE,SAAkC,EAAE;IACnF,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;YAC7C,IAAI,KAAK;gBAAE,MAAM,CAAC,KAAK,CAAC,CAAA;;gBACnB,OAAO,CAAC,QAAa,CAAC,CAAA;QAC/B,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,uBAAuB,CACzC,IAA0B,EAC1B,QAAgB,EAChB,MAAwB;IAExB,MAAM,OAAO,GAAG,IAAI,wBAAO,EAAE,CAAA;IAC7B,OA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,CAAC,UAAU,EAAE,CAAA;IACxB,CAAC;AACL,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const promises_1 = require("node:fs/promises");
4
+ const node_os_1 = require("node:os");
5
+ const node_path_1 = require("node:path");
6
+ const benchmark_profile_1 = require("./benchmark.profile");
7
+ describe('benchmark inspector profiles', () => {
8
+ it('captures a CPU profile and returns the action result', async () => {
9
+ const root = await (0, promises_1.mkdtemp)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'cobolts-cpu-profile-'));
10
+ try {
11
+ const filename = (0, node_path_1.join)(root, 'nested', 'sample.cpuprofile');
12
+ const result = await (0, benchmark_profile_1.captureBenchmarkProfile)('cpu', filename, async () => {
13
+ let total = 0;
14
+ for (let i = 0; i < 500_000; i++)
15
+ total += i;
16
+ return total;
17
+ });
18
+ expect(result).toEqual(124999750000);
19
+ const profile = JSON.parse(await (0, promises_1.readFile)(filename, 'utf8'));
20
+ expect(Array.isArray(profile.nodes)).toEqual(true);
21
+ expect(Array.isArray(profile.samples)).toEqual(true);
22
+ }
23
+ finally {
24
+ await (0, promises_1.rm)(root, { recursive: true, force: true });
25
+ }
26
+ });
27
+ it('captures allocation sampling, including short-lived objects', async () => {
28
+ const root = await (0, promises_1.mkdtemp)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'cobolts-allocation-profile-'));
29
+ try {
30
+ const filename = (0, node_path_1.join)(root, 'sample.heapprofile');
31
+ const result = await (0, benchmark_profile_1.captureBenchmarkProfile)('allocation', filename, async () => {
32
+ let count = 0;
33
+ for (let batch = 0; batch < 20; batch++) {
34
+ const values = Array.from({ length: 10_000 }, (_, i) => ({ value: String(i) }));
35
+ count += values.length;
36
+ }
37
+ return count;
38
+ });
39
+ expect(result).toEqual(200000);
40
+ const profile = JSON.parse(await (0, promises_1.readFile)(filename, 'utf8'));
41
+ expect(profile.head.callFrame.functionName).toEqual('(root)');
42
+ expect(Array.isArray(profile.samples)).toEqual(true);
43
+ }
44
+ finally {
45
+ await (0, promises_1.rm)(root, { recursive: true, force: true });
46
+ }
47
+ });
48
+ it('releases the profiler when the action throws', async () => {
49
+ const root = await (0, promises_1.mkdtemp)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'cobolts-profile-failure-'));
50
+ try {
51
+ const broken = (0, node_path_1.join)(root, 'broken.cpuprofile');
52
+ await expect((0, benchmark_profile_1.captureBenchmarkProfile)('cpu', broken, async () => {
53
+ throw new Error('Evaluation failed');
54
+ })).rejects.toThrow('Evaluation failed');
55
+ const filename = (0, node_path_1.join)(root, 'working.cpuprofile');
56
+ await expect((0, benchmark_profile_1.captureBenchmarkProfile)('cpu', filename, async () => 12)).resolves.toEqual(12);
57
+ const profile = JSON.parse(await (0, promises_1.readFile)(filename, 'utf8'));
58
+ expect(Array.isArray(profile.nodes)).toEqual(true);
59
+ }
60
+ finally {
61
+ await (0, promises_1.rm)(root, { recursive: true, force: true });
62
+ }
63
+ });
64
+ });
65
+ //# sourceMappingURL=benchmark.profile.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark.profile.spec.js","sourceRoot":"","sources":["../../src/benchmark.profile.spec.ts"],"names":[],"mappings":";;AAAA,+CAAsD;AACtD,qCAA8B;AAC9B,yCAA8B;AAC9B,2DAA2D;AAE3D,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC1C,EAAE,CAAC,sDAAsD,EAAE,KAAK,IAAI,EAAE;QAClE,MAAM,IAAI,GAAG,MAAM,IAAA,kBAAO,EAAC,IAAA,gBAAI,EAAC,IAAA,gBAAM,GAAE,EAAE,sBAAsB,CAAC,CAAC,CAAA;QAClE,IAAI,CAAC;YACD,MAAM,QAAQ,GAAG,IAAA,gBAAI,EAAC,IAAI,EAAE,QAAQ,EAAE,mBAAmB,CAAC,CAAA;YAC1D,MAAM,MAAM,GAAG,MAAM,IAAA,2CAAuB,EAAC,KAAK,EAAE,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MAAM,EAAE,KAAK,IAAI,EAAE;gBAC3D,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;YACxC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;YACxC,MAAM,QAAQ,GAAG,IAAA,gBAAI,EAAC,IAAI,EAAE,oBAAoB,CAAC,CAAA;YACjD,MAAM,MAAM,CAAC,IAAA,2CAAuB,EAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YAC3F,MAAM,OAAO,GAAuB,IAAI,CAAC,KAAK,CAAC,MAAM,IAAA,mBAAQ,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAA;YAChF,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACtD,CAAC;gBAAS,CAAC;YACP,MAAM,IAAA,aAAE,EAAC,IAAI,EAAE,EAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC,CAAA;QAClD,CAAC;IACL,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { type BenchmarkReport } from './benchmark.report';
2
+ export interface RecordedBenchmark {
3
+ readonly version: 1;
4
+ readonly runId: string;
5
+ readonly recordedAt: string;
6
+ readonly options: Readonly<Record<string, unknown>>;
7
+ readonly report: BenchmarkReport;
8
+ }
9
+ export interface RecordedSuite extends Omit<RecordedBenchmark, 'report'> {
10
+ readonly reports: readonly BenchmarkReport[];
11
+ }
12
+ /** A shared identity for all projects measured by one CLI invocation. */
13
+ export declare function benchmarkRecorder(options: Readonly<Record<string, unknown>>, started?: Date): {
14
+ project: (report: BenchmarkReport, lines?: readonly string[]) => Promise<string>;
15
+ suite: (root: string, reports: readonly BenchmarkReport[], lines: readonly string[]) => Promise<string>;
16
+ };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.benchmarkRecorder = benchmarkRecorder;
4
+ const node_crypto_1 = require("node:crypto");
5
+ const files_node_1 = require("@cobol-ts/files-node");
6
+ const node_path_1 = require("node:path");
7
+ const benchmark_report_1 = require("./benchmark.report");
8
+ const { mkdir, writeFile, rm } = files_node_1.nodeLocalFiles.promises;
9
+ /** A shared identity for all projects measured by one CLI invocation. */
10
+ function benchmarkRecorder(options, started = new Date()) {
11
+ const recordedAt = started.toISOString();
12
+ const runId = `${recordedAt.replace(/:/g, '-')}-${(0, node_crypto_1.randomUUID)()}`;
13
+ const metadata = { version: 1, runId, recordedAt, options };
14
+ let sequence = 0;
15
+ const save = async (root, name, value, lines) => {
16
+ const directory = (0, node_path_1.join)(root, 'benchmark-results', recordedAt.slice(0, 10));
17
+ const filename = (0, node_path_1.join)(directory, name);
18
+ await mkdir(directory, { recursive: true });
19
+ await writeFile(`${filename}.txt`, [`RECORDED ${recordedAt}`, `RUN ID ${runId}`, ...lines].join('\n') + '\n', { flag: 'wx' });
20
+ try {
21
+ await writeFile(`${filename}.json`, JSON.stringify(value, null, 2) + '\n', { flag: 'wx' });
22
+ }
23
+ catch (error) {
24
+ await rm(`${filename}.txt`);
25
+ throw error;
26
+ }
27
+ return `${filename}.json`;
28
+ };
29
+ return {
30
+ project: (report, lines = (0, benchmark_report_1.formatBenchmarkReport)(report)) => save(report.project, `${runId}-${++sequence}`, { ...metadata, report }, lines),
31
+ suite: (root, reports, lines) => save(root, `${runId}-suite`, { ...metadata, reports }, [...lines, ...(0, benchmark_report_1.formatBenchmarkSuiteSummary)(reports)])
32
+ };
33
+ }
34
+ //# sourceMappingURL=benchmark.record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark.record.js","sourceRoot":"","sources":["../../src/benchmark.record.ts"],"names":[],"mappings":";;AAoBA,8CAwB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