@eagleoutice/flowr 2.13.12 → 2.13.14

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 (77) hide show
  1. package/README.md +29 -26
  2. package/benchmark/calibration.d.ts +18 -0
  3. package/benchmark/calibration.js +63 -0
  4. package/benchmark/slicer.d.ts +19 -0
  5. package/benchmark/slicer.js +84 -1
  6. package/benchmark/stats/feature-counts.d.ts +6 -0
  7. package/benchmark/stats/feature-counts.js +61 -0
  8. package/benchmark/stats/print.js +20 -0
  9. package/benchmark/stats/sigdb-counts.d.ts +7 -0
  10. package/benchmark/stats/sigdb-counts.js +219 -0
  11. package/benchmark/stats/size-of.d.ts +6 -0
  12. package/benchmark/stats/size-of.js +8 -0
  13. package/benchmark/stats/stats.d.ts +79 -0
  14. package/benchmark/stats/stats.js +7 -1
  15. package/benchmark/stopwatch.d.ts +4 -0
  16. package/benchmark/stopwatch.js +12 -1
  17. package/benchmark/summarizer/data.d.ts +17 -1
  18. package/benchmark/summarizer/first-phase/input.js +5 -0
  19. package/benchmark/summarizer/first-phase/process.js +12 -2
  20. package/benchmark/summarizer/second-phase/graph.d.ts +1 -1
  21. package/benchmark/summarizer/second-phase/graph.js +214 -16
  22. package/benchmark/summarizer/second-phase/process.js +56 -0
  23. package/benchmark/summarizer/summarizer.js +1 -2
  24. package/cli/benchmark-app.d.ts +1 -0
  25. package/cli/benchmark-app.js +2 -1
  26. package/cli/benchmark-helper-app.d.ts +1 -0
  27. package/cli/benchmark-helper-app.js +12 -2
  28. package/cli/common/options.d.ts +10 -0
  29. package/cli/common/options.js +3 -1
  30. package/cli/common/scripts-info.d.ts +10 -0
  31. package/config.js +13 -7
  32. package/control-flow/cfg-builder.d.ts +30 -0
  33. package/control-flow/cfg-builder.js +79 -0
  34. package/control-flow/extract-cfg.js +17 -10
  35. package/dataflow/environments/apply-kill.d.ts +3 -3
  36. package/dataflow/environments/apply-kill.js +60 -31
  37. package/dataflow/environments/reference-to-maybe.d.ts +5 -3
  38. package/dataflow/environments/reference-to-maybe.js +17 -52
  39. package/dataflow/environments/resolve-helper.d.ts +2 -1
  40. package/dataflow/environments/resolve-helper.js +2 -1
  41. package/dataflow/graph/df-helper.d.ts +2 -1
  42. package/dataflow/info.d.ts +7 -1
  43. package/dataflow/info.js +36 -7
  44. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +33 -10
  45. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +4 -1
  46. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +6 -2
  47. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -1
  48. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +7 -2
  49. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +8 -1
  50. package/documentation/doc-readme.js +5 -2
  51. package/documentation/doc-util/doc-issue.d.ts +2 -0
  52. package/documentation/doc-util/doc-issue.js +3 -1
  53. package/documentation/wiki-analyzer.js +10 -4
  54. package/documentation/wiki-core.js +58 -0
  55. package/documentation/wiki-dataflow-graph.js +4 -0
  56. package/documentation/wiki-faq.js +6 -2
  57. package/documentation/wiki-onboarding.js +11 -1
  58. package/documentation/wiki-setup.js +2 -1
  59. package/gas.d.ts +56 -6
  60. package/package.json +9 -4
  61. package/project/cache/flowr-analyzer-cache.d.ts +1 -0
  62. package/project/cache/flowr-analyzer-cache.js +4 -0
  63. package/project/context/flowr-analyzer-context.js +5 -0
  64. package/project/context/flowr-analyzer-gas-context.d.ts +58 -4
  65. package/project/context/flowr-analyzer-gas-context.js +137 -15
  66. package/project/flowr-analyzer.d.ts +25 -7
  67. package/project/flowr-analyzer.js +6 -6
  68. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +11 -9
  69. package/slicing/static/slice-call.js +4 -4
  70. package/slicing/static/slicer-types.d.ts +13 -0
  71. package/slicing/static/static-slicer.d.ts +7 -1
  72. package/slicing/static/static-slicer.js +11 -5
  73. package/slicing/static/visiting-queue.d.ts +3 -1
  74. package/slicing/static/visiting-queue.js +4 -1
  75. package/util/node-version.d.ts +4 -0
  76. package/util/node-version.js +29 -0
  77. package/util/version.js +1 -1
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.countSignatureDatabase = countSignatureDatabase;
7
+ /**
8
+ * Counts what the signature database mounted on the benchmarking machine carries, so a release also shows
9
+ * how the database grew. Everything is read from the manifests and the bundle headers, i.e. without unpacking
10
+ * a bundle, the one exception being the small base-R bundle whose entries are walked for {@link SigDbBaseCounts}.
11
+ * @module
12
+ */
13
+ const fs_1 = __importDefault(require("fs"));
14
+ const path_1 = __importDefault(require("path"));
15
+ const manifest_1 = require("../../project/sigdb/manifest");
16
+ const decompress_1 = require("../../project/sigdb/decompress");
17
+ const index_format_1 = require("../../project/sigdb/index-format");
18
+ const reader_1 = require("../../project/sigdb/reader");
19
+ const schema_1 = require("../../project/sigdb/schema");
20
+ /** what a temporal tier of a bundle keeps, in the words the wiki uses for it */
21
+ const KindOfTier = {
22
+ current: 'latest only',
23
+ full: 'full history',
24
+ history: 'older only'
25
+ };
26
+ const ManifestFile = /\.manifest\.json(\.(br|zst|gz))?$/;
27
+ function sizeOf(file) {
28
+ try {
29
+ return fs_1.default.statSync(file).size;
30
+ }
31
+ catch {
32
+ return 0;
33
+ }
34
+ }
35
+ async function contentOf(file) {
36
+ try {
37
+ return (await (0, decompress_1.readHeaderOf)(file))?.content;
38
+ }
39
+ catch {
40
+ return undefined;
41
+ }
42
+ }
43
+ /** the kind a shard belongs to, falling back to its tier so an unknown tier still gets a counter of its own */
44
+ function kindOf(tier) {
45
+ const name = String(tier ?? 'unknown');
46
+ return KindOfTier[name] ?? name;
47
+ }
48
+ function add(into, key, value) {
49
+ into[key] = (into[key] ?? 0) + value;
50
+ }
51
+ /**
52
+ * Every distinct shard of every discovered bundle, plus the dictionaries and manifests they need. A shard id a
53
+ * later manifest ships again is skipped (the two copies hold the same packages), and with it that manifest's
54
+ * dictionary, so nothing is counted twice.
55
+ */
56
+ function collectBundles(paths) {
57
+ const bundles = [];
58
+ const seen = new Set();
59
+ let dictionaries = 0;
60
+ let manifests = 0;
61
+ for (const p of paths) {
62
+ if (!ManifestFile.test(p)) {
63
+ // a standalone bundle, which is a database of one shard without a manifest around it
64
+ const id = path_1.default.basename(p);
65
+ if (!seen.has(id)) {
66
+ seen.add(id);
67
+ bundles.push({ id, ref: { id, tier: 'full', path: p, hash: '', packages: 0, versions: 0 }, file: p, manifest: undefined });
68
+ }
69
+ continue;
70
+ }
71
+ let manifest;
72
+ try {
73
+ manifest = (0, manifest_1.readManifestFile)(p);
74
+ }
75
+ catch (e) {
76
+ console.log(` skipping signature database manifest ${p}: ${e.message}`);
77
+ continue;
78
+ }
79
+ const baseDir = path_1.default.dirname(p);
80
+ const own = (manifest.shards ?? []).filter(s => s?.id !== undefined && !seen.has(s.id));
81
+ if (own.length === 0) {
82
+ continue;
83
+ }
84
+ for (const ref of own) {
85
+ seen.add(ref.id);
86
+ bundles.push({ id: ref.id, ref, file: (0, decompress_1.resolveSource)(baseDir, ref.path), manifest });
87
+ }
88
+ manifests += sizeOf(p);
89
+ for (const dict of manifest.dicts ?? []) {
90
+ dictionaries += sizeOf((0, decompress_1.resolveSource)(baseDir, dict.path));
91
+ }
92
+ }
93
+ return { bundles, dictionaries, manifests };
94
+ }
95
+ /** every package name the bundles route, so the same package in several bundles is only counted once */
96
+ function countPackages(bundles) {
97
+ const names = new Set();
98
+ for (const { ref, manifest } of bundles) {
99
+ for (const name of Object.keys(ref.idx?.p ?? {})) {
100
+ names.add(name);
101
+ }
102
+ for (const name of Object.keys(manifest?.meta ?? {})) {
103
+ names.add(name);
104
+ }
105
+ }
106
+ return names.size > 0 ? names.size : Math.max(0, ...bundles.map(b => b.ref.packages ?? 0));
107
+ }
108
+ /**
109
+ * Walk the base-R bundle of the newest R release and count what its function records carry. It is a few
110
+ * hundred KiB unpacked, so this stays in the milliseconds; only the numeric tuples are read, no string
111
+ * dictionary is needed for them.
112
+ */
113
+ async function countBaseEntries(bundles) {
114
+ const base = bundles.find(b => b.ref.tier === 'current' && b.id.startsWith('base'));
115
+ if (base === undefined) {
116
+ return undefined;
117
+ }
118
+ let db;
119
+ try {
120
+ db = await reader_1.SigDatabase.open(base.file, {
121
+ hash: base.ref.hash,
122
+ index: base.ref.idx ? (0, index_format_1.decodeIndex)(base.ref.idx, base.manifest?.meta) : undefined
123
+ });
124
+ const carrying = {
125
+ 'with parameters': 0,
126
+ 'with a call graph': 0,
127
+ 'with a source location': 0,
128
+ 'with a help topic': 0
129
+ };
130
+ for (const name of Object.values(schema_1.FnPropNames)) {
131
+ carrying[name] = 0;
132
+ }
133
+ let functions = 0;
134
+ let parameters = 0;
135
+ for (const blob of db.allBlobs()) {
136
+ for (const fn of blob.fns ?? []) {
137
+ functions++;
138
+ const [, sigIdx, cgIdx, props, fileIdx] = fn;
139
+ if (sigIdx >= 0) {
140
+ carrying['with parameters']++;
141
+ parameters += blob.sigs[sigIdx]?.length ?? 0;
142
+ }
143
+ if (cgIdx >= 0) {
144
+ carrying['with a call graph']++;
145
+ }
146
+ if (fileIdx >= 0) {
147
+ carrying['with a source location']++;
148
+ }
149
+ if (fn.length > 6) {
150
+ carrying['with a help topic']++;
151
+ }
152
+ for (const [bit, name] of Object.entries(schema_1.FnPropNames)) {
153
+ if ((props & Number(bit)) !== 0) {
154
+ carrying[name]++;
155
+ }
156
+ }
157
+ }
158
+ }
159
+ return { functions, parameters, functionsCarrying: carrying };
160
+ }
161
+ catch (e) {
162
+ console.log(` skipping the signature database entry breakdown: ${e.message}`);
163
+ return undefined;
164
+ }
165
+ finally {
166
+ db?.close();
167
+ }
168
+ }
169
+ /**
170
+ * Counts the bundles of the mounted signature database, what they describe, and what they occupy.
171
+ * Every step is defensive, as this also runs against older databases when the history is filled in, and a
172
+ * machine without a mounted database simply yields `undefined` instead of failing the benchmark.
173
+ */
174
+ async function countSignatureDatabase() {
175
+ let paths;
176
+ try {
177
+ paths = (0, manifest_1.defaultSigDbPaths)();
178
+ }
179
+ catch (e) {
180
+ console.log(` no signature database counted: ${e.message}`);
181
+ return undefined;
182
+ }
183
+ const { bundles, dictionaries, manifests } = collectBundles(paths);
184
+ if (bundles.length === 0) {
185
+ console.log(' no signature database is mounted, its counters are left out');
186
+ return undefined;
187
+ }
188
+ const bundlesByKind = {};
189
+ const functionsByKind = {};
190
+ const sizeByKind = {};
191
+ let packageVersions = 0;
192
+ let functions = 0;
193
+ let size = dictionaries + manifests;
194
+ for (const bundle of bundles) {
195
+ const content = await contentOf(bundle.file);
196
+ const kind = kindOf(content?.tier ?? bundle.ref.tier);
197
+ const bytes = sizeOf(bundle.file);
198
+ add(bundlesByKind, kind, 1);
199
+ add(functionsByKind, kind, content?.functions ?? 0);
200
+ add(sizeByKind, kind, bytes);
201
+ packageVersions += content?.versions ?? bundle.ref.versions ?? 0;
202
+ functions += content?.functions ?? 0;
203
+ size += bytes;
204
+ }
205
+ return {
206
+ bundles: bundles.length,
207
+ bundlesByKind,
208
+ packages: countPackages(bundles),
209
+ packageVersions,
210
+ functions,
211
+ functionsByKind,
212
+ sizeByKind,
213
+ sizeOfDictionaries: dictionaries,
214
+ sizeOfManifests: manifests,
215
+ size,
216
+ base: await countBaseEntries(bundles)
217
+ };
218
+ }
219
+ //# sourceMappingURL=sigdb-counts.js.map
@@ -1,6 +1,12 @@
1
1
  import type { DataflowGraph } from '../../dataflow/graph/graph';
2
+ import type { ControlFlowGraph } from '../../control-flow/control-flow-graph';
2
3
  /** Returns the size of the given df graph in bytes (without sharing in-memory) */
3
4
  export declare function getSizeOfDfGraph(df: DataflowGraph): number;
5
+ /**
6
+ * Calculates the size of the control flow graph in bytes, counting its vertices and edges like
7
+ * {@link getSizeOfDfGraph} does for the dataflow graph.
8
+ */
9
+ export declare function getSizeOfCfGraph(cfg: ControlFlowGraph): number;
4
10
  /**
5
11
  * Calculates the size of an array in bytes.
6
12
  * @param array - The array to calculate the size of.
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getSizeOfDfGraph = getSizeOfDfGraph;
7
+ exports.getSizeOfCfGraph = getSizeOfCfGraph;
7
8
  exports.safeSizeOf = safeSizeOf;
8
9
  const vertex_1 = require("../../dataflow/graph/vertex");
9
10
  const identifier_1 = require("../../dataflow/environments/identifier");
@@ -68,6 +69,13 @@ function getSizeOfDfGraph(df) {
68
69
  }
69
70
  return safeSizeOf([...verts, ...df.edges()]);
70
71
  }
72
+ /**
73
+ * Calculates the size of the control flow graph in bytes, counting its vertices and edges like
74
+ * {@link getSizeOfDfGraph} does for the dataflow graph.
75
+ */
76
+ function getSizeOfCfGraph(cfg) {
77
+ return safeSizeOf([...cfg.vertices(true).values(), ...cfg.edges()]);
78
+ }
71
79
  /**
72
80
  * Calculates the size of an array in bytes.
73
81
  * @param array - The array to calculate the size of.
@@ -11,6 +11,13 @@ export declare const CommonSlicerMeasurements: readonly ["initialize R session",
11
11
  export type CommonSlicerMeasurements = typeof CommonSlicerMeasurements[number];
12
12
  export declare const PerSliceMeasurements: readonly ["static slicing", "reconstruct code", "total"];
13
13
  export type PerSliceMeasurements = typeof PerSliceMeasurements[number];
14
+ /**
15
+ * Measurements that are taken *after* all {@link CommonSlicerMeasurements} and hence do not count towards them
16
+ * (especially not towards the `total`).
17
+ * They may be missing if the corresponding phase failed or was never run.
18
+ */
19
+ export declare const AdditionalSlicerMeasurements: readonly ["dependencies query", "linter run", "calibration"];
20
+ export type AdditionalSlicerMeasurements = typeof AdditionalSlicerMeasurements[number];
14
21
  export type ElapsedTime = bigint;
15
22
  export interface PerSliceStats {
16
23
  measurements: Map<PerSliceMeasurements, ElapsedTime>;
@@ -41,6 +48,69 @@ export interface SlicerStatsDataflow<T = number> {
41
48
  numberOfFunctionDefinitions: T;
42
49
  sizeOfObject: T;
43
50
  }
51
+ /** what the benchmarked flowR version carries, counted once per run */
52
+ export interface FlowrFeatureCounts {
53
+ lintingRules: number;
54
+ queries: number;
55
+ builtinDefinitions: number;
56
+ /** built-ins handled by the default processor, which only reads its arguments */
57
+ builtinDefinitionsDefault: number;
58
+ /** built-ins with a processor of their own */
59
+ builtinDefinitionsCustom: number;
60
+ /** built-ins that also carry a value solver, see the built-in eval handlers */
61
+ builtinDefinitionsWithEvalHandler: number;
62
+ /** how many linting rules carry each tag, a rule usually carries several */
63
+ lintingRulesByTag: Record<string, number>;
64
+ }
65
+ /**
66
+ * What the entries of the base-R bundle carry, counted by walking its function records once.
67
+ * Only that one bundle is walked, it is the part every install ships and the only one small enough
68
+ * to read without unpacking megabytes (see {@link SigDbCounts}).
69
+ */
70
+ export interface SigDbBaseCounts {
71
+ /** unique function records in the bundle's pool (a record shared by several versions counts once) */
72
+ readonly functions: number;
73
+ /** total number of parameters over all of those records */
74
+ readonly parameters: number;
75
+ /**
76
+ * how many of the records carry each piece of information: a parameter list, a call graph, a source
77
+ * location, a help topic, and one entry per function property flag the format defines
78
+ */
79
+ readonly functionsCarrying: Record<string, number>;
80
+ }
81
+ /**
82
+ * What the signature database mounted on the benchmarking machine carries, counted once per run.
83
+ * `undefined` when no database is mounted. Bundles are the distinct shards of the discovered manifests
84
+ * (a shard a second manifest ships again is counted once), and a *kind* is a shard's temporal tier.
85
+ */
86
+ export interface SigDbCounts {
87
+ /** distinct shards over all discovered bundles */
88
+ readonly bundles: number;
89
+ /** how many bundles each kind contributes, e.g. `latest only` or `full history` */
90
+ readonly bundlesByKind: Record<string, number>;
91
+ /** distinct package names the database describes */
92
+ readonly packages: number;
93
+ /** package versions the bundles store, summed (a kind-wise split would overlap, so there is none) */
94
+ readonly packageVersions: number;
95
+ /** function records the bundles store, summed over the bundles */
96
+ readonly functions: number;
97
+ /** function records per kind, a partition: every record belongs to exactly one bundle */
98
+ readonly functionsByKind: Record<string, number>;
99
+ /** bytes the bundles of each kind occupy on disk, in the codec this runtime reads */
100
+ readonly sizeByKind: Record<string, number>;
101
+ /** bytes of the shared string dictionaries */
102
+ readonly sizeOfDictionaries: number;
103
+ /** bytes of the manifests themselves */
104
+ readonly sizeOfManifests: number;
105
+ /** bytes of everything the database occupies */
106
+ readonly size: number;
107
+ readonly base?: SigDbBaseCounts;
108
+ }
109
+ export interface SlicerStatsControlFlow<T = number> {
110
+ numberOfVertices: T;
111
+ numberOfEdges: T;
112
+ sizeOfObject: T;
113
+ }
44
114
  export interface SlicerStatsDfShape<T = number> {
45
115
  numberOfDataFrameFiles: T extends number ? 0 | 1 : number;
46
116
  numberOfNonDataFrameFiles: T extends number ? 0 | 1 : number;
@@ -81,10 +151,13 @@ export interface BenchmarkMemoryMeasurement<T = number> extends MergeableRecord
81
151
  export interface SlicerStats {
82
152
  commonMeasurements: Map<CommonSlicerMeasurements, ElapsedTime>;
83
153
  perSliceMeasurements: Map<SlicingCriteria, PerSliceStats>;
154
+ /** measured after all {@link commonMeasurements}, see {@link AdditionalSlicerMeasurements} */
155
+ additionalMeasurements: Map<AdditionalSlicerMeasurements, ElapsedTime>;
84
156
  memory: Map<CommonSlicerMeasurements, BenchmarkMemoryMeasurement>;
85
157
  request: RParseRequestFromFile | RParseRequestFromText;
86
158
  input: SlicerStatsInput;
87
159
  dataflow: SlicerStatsDataflow;
160
+ controlFlow?: SlicerStatsControlFlow;
88
161
  dataFrameShape?: SlicerStatsDfShape;
89
162
  retrieveTimePerToken: TimePerToken<number>;
90
163
  normalizeTimePerToken: TimePerToken<number>;
@@ -93,4 +166,10 @@ export interface SlicerStats {
93
166
  controlFlowTimePerToken?: TimePerToken<number>;
94
167
  callGraphTimePerToken?: TimePerToken<number>;
95
168
  dataFrameShapeTimePerToken?: TimePerToken<number>;
169
+ /** time in nanoseconds per 100 lines of the input, the pendant to {@link retrieveTimePerToken} */
170
+ retrieveTimePer100Lines: number;
171
+ normalizeTimePer100Lines: number;
172
+ dataflowTimePer100Lines: number;
173
+ totalCommonTimePer100Lines: number;
174
+ controlFlowTimePer100Lines?: number;
96
175
  }
@@ -1,8 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PerSliceMeasurements = exports.CommonSlicerMeasurements = exports.OptionalSlicerMeasurements = exports.RequiredSlicerMeasurements = void 0;
3
+ exports.AdditionalSlicerMeasurements = exports.PerSliceMeasurements = exports.CommonSlicerMeasurements = exports.OptionalSlicerMeasurements = exports.RequiredSlicerMeasurements = void 0;
4
4
  exports.RequiredSlicerMeasurements = ['initialize R session', 'retrieve AST from R code', 'normalize R AST', 'produce dataflow information', 'close R session', 'total'];
5
5
  exports.OptionalSlicerMeasurements = ['extract control flow graph', 'infer data frame shapes', 'extract call graph'];
6
6
  exports.CommonSlicerMeasurements = [...exports.RequiredSlicerMeasurements, ...exports.OptionalSlicerMeasurements];
7
7
  exports.PerSliceMeasurements = ['static slicing', 'reconstruct code', 'total'];
8
+ /**
9
+ * Measurements that are taken *after* all {@link CommonSlicerMeasurements} and hence do not count towards them
10
+ * (especially not towards the `total`).
11
+ * They may be missing if the corresponding phase failed or was never run.
12
+ */
13
+ exports.AdditionalSlicerMeasurements = ['dependencies query', 'linter run', 'calibration'];
8
14
  //# sourceMappingURL=stats.js.map
@@ -1,6 +1,10 @@
1
1
  export interface IStoppableStopwatch {
2
2
  /** Stop the given stopwatch. */
3
3
  stop(): void;
4
+ /** Exclude everything that happens until the next {@link resume} from the elapsed time. */
5
+ pause(): void;
6
+ /** Continue after a {@link pause}, does nothing if the stopwatch is not paused. */
7
+ resume(): void;
4
8
  }
5
9
  /**
6
10
  * Allows to measure keys of type `T` with a `Stopwatch`.
@@ -6,6 +6,8 @@ const assert_1 = require("../util/assert");
6
6
  class Stopwatch {
7
7
  timeStart;
8
8
  timeEnd;
9
+ pauseStart;
10
+ pausedTotal = 0n;
9
11
  stopped = false;
10
12
  start() {
11
13
  this.timeStart = process.hrtime.bigint();
@@ -16,9 +18,18 @@ class Stopwatch {
16
18
  (0, assert_1.guard)(!this.stopped, 'cannot stop a stopwatch twice');
17
19
  this.stopped = true;
18
20
  }
21
+ pause() {
22
+ this.pauseStart ??= process.hrtime.bigint();
23
+ }
24
+ resume() {
25
+ if (this.pauseStart !== undefined) {
26
+ this.pausedTotal += process.hrtime.bigint() - this.pauseStart;
27
+ this.pauseStart = undefined;
28
+ }
29
+ }
19
30
  get() {
20
31
  (0, assert_1.guard)(this.timeStart !== undefined && this.timeEnd !== undefined, 'cannot get elapsed time as the stopwatch has not been started/stopped');
21
- return this.timeEnd - this.timeStart;
32
+ return this.timeEnd - this.timeStart - this.pausedTotal;
22
33
  }
23
34
  }
24
35
  /**
@@ -1,6 +1,6 @@
1
1
  import type { DataFrameOperationName } from '../../abstract-interpretation/data-frame/semantics';
2
2
  import type { SummarizedMeasurement } from '../../util/summarizer';
3
- import type { CommonSlicerMeasurements, PerSliceMeasurements, SlicerStats, SlicerStatsDfShape, SlicerStatsDataflow, SlicerStatsInput } from '../stats/stats';
3
+ import type { AdditionalSlicerMeasurements, CommonSlicerMeasurements, PerSliceMeasurements, SlicerStats, SlicerStatsDfShape, SlicerStatsControlFlow, SlicerStatsDataflow, SlicerStatsInput } from '../stats/stats';
4
4
  export interface SliceSizeCollection {
5
5
  lines: number[];
6
6
  nonEmptyLines: number[];
@@ -46,6 +46,10 @@ export interface SummarizedPerSliceStats {
46
46
  sliceTimePerToken: TimePerToken;
47
47
  reconstructTimePerToken: TimePerToken;
48
48
  totalPerSliceTimePerToken: TimePerToken;
49
+ /** the per 100 lines of input pendant to {@link sliceTimePerToken} */
50
+ sliceTimePer100Lines: SummarizedMeasurement;
51
+ reconstructTimePer100Lines: SummarizedMeasurement;
52
+ totalPerSliceTimePer100Lines: SummarizedMeasurement;
49
53
  reduction: Reduction<SummarizedMeasurement>;
50
54
  /** reduction, but without taking into account comments and empty lines */
51
55
  reductionNoFluff: Reduction<SummarizedMeasurement>;
@@ -60,6 +64,8 @@ export interface UltimateSlicerStats {
60
64
  totalSlices: number;
61
65
  commonMeasurements: Map<CommonSlicerMeasurements, SummarizedMeasurement>;
62
66
  perSliceMeasurements: Map<PerSliceMeasurements, SummarizedMeasurement>;
67
+ /** measured after all {@link commonMeasurements}, see {@link AdditionalSlicerMeasurements} */
68
+ additionalMeasurements: Map<AdditionalSlicerMeasurements, SummarizedMeasurement>;
63
69
  retrieveTimePerToken: TimePerToken;
64
70
  normalizeTimePerToken: TimePerToken;
65
71
  dataflowTimePerToken: TimePerToken;
@@ -70,6 +76,15 @@ export interface UltimateSlicerStats {
70
76
  sliceTimePerToken: TimePerToken;
71
77
  reconstructTimePerToken: TimePerToken;
72
78
  totalPerSliceTimePerToken: TimePerToken;
79
+ /** the per 100 lines of input pendant to {@link retrieveTimePerToken} */
80
+ retrieveTimePer100Lines: SummarizedMeasurement;
81
+ normalizeTimePer100Lines: SummarizedMeasurement;
82
+ dataflowTimePer100Lines: SummarizedMeasurement;
83
+ totalCommonTimePer100Lines: SummarizedMeasurement;
84
+ controlFlowTimePer100Lines?: SummarizedMeasurement;
85
+ sliceTimePer100Lines: SummarizedMeasurement;
86
+ reconstructTimePer100Lines: SummarizedMeasurement;
87
+ totalPerSliceTimePer100Lines: SummarizedMeasurement;
73
88
  /** sum */
74
89
  failedToRepParse: number;
75
90
  /** sum */
@@ -79,6 +94,7 @@ export interface UltimateSlicerStats {
79
94
  reductionNoFluff: Reduction<SummarizedMeasurement>;
80
95
  input: SlicerStatsInput<SummarizedMeasurement>;
81
96
  dataflow: SlicerStatsDataflow<SummarizedMeasurement>;
97
+ controlFlow?: SlicerStatsControlFlow<SummarizedMeasurement>;
82
98
  dataFrameShape?: SummarizedDfShapeStats<SummarizedMeasurement>;
83
99
  }
84
100
  export interface SummarizedDfShapeStats<T = number> extends Omit<SlicerStatsDfShape<T>, 'perNodeStats'> {
@@ -30,6 +30,11 @@ async function processRunMeasurement(line, fileNum, lineNum, textOutputAppendPat
30
30
  (0, assert_1.guard)(v.endsWith('n'), 'Expected a bigint');
31
31
  return [k, BigInt(v.slice(0, -1))];
32
32
  })),
33
+ additionalMeasurements: new Map((got.stats.additionalMeasurements ?? [])
34
+ .map(([k, v]) => {
35
+ (0, assert_1.guard)(v.endsWith('n'), 'Expected a bigint');
36
+ return [k, BigInt(v.slice(0, -1))];
37
+ })),
33
38
  perSliceMeasurements: new Map(got.stats.perSliceMeasurements
34
39
  .map(([k, v]) => mapPerSliceStats(k, v))),
35
40
  dataFrameShape: got.stats.dataFrameShape !== undefined ? {
@@ -115,6 +115,10 @@ async function summarizeSlicerStats(stats, report = () => {
115
115
  const sliceTimes = [];
116
116
  const reconstructTimes = [];
117
117
  const totalTimes = [];
118
+ const sliceTimesPer100Lines = [];
119
+ const reconstructTimesPer100Lines = [];
120
+ const totalTimesPer100Lines = [];
121
+ const per100Lines = 100 / stats.input.numberOfLines;
118
122
  const reductions = [];
119
123
  const reductionsNoFluff = [];
120
124
  let failedOutputs = 0;
@@ -140,6 +144,11 @@ async function summarizeSlicerStats(stats, report = () => {
140
144
  }
141
145
  sizeOfSliceCriteria.push(perSliceStat.slicingCriteria.length);
142
146
  timesHitThreshold += perSliceStat.timesHitThreshold > 0 ? 1 : 0;
147
+ const sliceTime = Number(perSliceStat.measurements.get('static slicing'));
148
+ const reconstructTime = Number(perSliceStat.measurements.get('reconstruct code'));
149
+ sliceTimesPer100Lines.push(sliceTime * per100Lines);
150
+ reconstructTimesPer100Lines.push(reconstructTime * per100Lines);
151
+ totalTimesPer100Lines.push((sliceTime + reconstructTime) * per100Lines);
143
152
  const { code: output, linesWithAutoSelected } = perSliceStat.reconstructedCode;
144
153
  sliceSize.linesWithAutoSelected.push(linesWithAutoSelected);
145
154
  const split = output.split('\n');
@@ -196,8 +205,6 @@ async function summarizeSlicerStats(stats, report = () => {
196
205
  };
197
206
  reductions.push(calculateReductionForSlice(stats.input, stats.dataflow, perSlice, false));
198
207
  reductionsNoFluff.push(calculateReductionForSlice(stats.input, stats.dataflow, perSlice, true));
199
- const sliceTime = Number(perSliceStat.measurements.get('static slicing'));
200
- const reconstructTime = Number(perSliceStat.measurements.get('reconstruct code'));
201
208
  sliceTimes.push({
202
209
  raw: sliceTime / numberOfRTokens,
203
210
  normalized: sliceTime / numberOfNormalizedTokens
@@ -237,6 +244,9 @@ async function summarizeSlicerStats(stats, report = () => {
237
244
  sliceTimePerToken: summarizeTimePerToken(sliceTimes),
238
245
  reconstructTimePerToken: summarizeTimePerToken(reconstructTimes),
239
246
  totalPerSliceTimePerToken: summarizeTimePerToken(totalTimes),
247
+ sliceTimePer100Lines: (0, summarizer_1.summarizeMeasurement)(sliceTimesPer100Lines),
248
+ reconstructTimePer100Lines: (0, summarizer_1.summarizeMeasurement)(reconstructTimesPer100Lines),
249
+ totalPerSliceTimePer100Lines: (0, summarizer_1.summarizeMeasurement)(totalTimesPer100Lines),
240
250
  sliceSize: {
241
251
  lines: (0, summarizer_1.summarizeMeasurement)(sliceSize.lines),
242
252
  nonEmptyLines: (0, summarizer_1.summarizeMeasurement)(sliceSize.nonEmptyLines),
@@ -4,4 +4,4 @@ import type { UltimateSlicerStats } from '../data';
4
4
  * @param ultimate - The ultimate slicer stats
5
5
  * @param outputGraphPath - The path to write the graph output to
6
6
  */
7
- export declare function writeGraphOutput(ultimate: UltimateSlicerStats, outputGraphPath: string): void;
7
+ export declare function writeGraphOutput(ultimate: UltimateSlicerStats, outputGraphPath: string): Promise<void>;