@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
package/README.md CHANGED
@@ -43,7 +43,7 @@ It offers a wide variety of features, for example:
43
43
 
44
44
  ```shell
45
45
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
46
- flowR repl v2.13.11, R grammar v14 (tree-sitter engine)
46
+ flowR repl v2.13.12, R grammar v14 (tree-sitter engine)
47
47
  R> :query @linter "read.csv(\"/root/x.txt\")"
48
48
  ```
49
49
 
@@ -52,7 +52,7 @@ It offers a wide variety of features, for example:
52
52
 
53
53
 
54
54
  ```text
55
- Query: linter (6 ms)
55
+ Query: linter (9 ms)
56
56
  ╰ Deprecated Functions (deprecated-functions): no findings
57
57
  ╰ File Path Validity (file-path-validity):
58
58
  ╰ certain:
@@ -62,7 +62,7 @@ It offers a wide variety of features, for example:
62
62
  ╰ Absolute Paths (absolute-file-paths):
63
63
  ╰ certain:
64
64
  ╰ Path `/root/x.txt` at 1.1-23
65
- ╰ Metadata: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 1, processTimeMs: 0
65
+ ╰ Metadata: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 0, processTimeMs: 0
66
66
  ╰ Unused Definitions (unused-definitions): no findings
67
67
  ╰ Network Functions (network-functions): no findings
68
68
  ╰ Dataframe Access Validation (dataframe-access-validation): no findings
@@ -73,7 +73,7 @@ It offers a wide variety of features, for example:
73
73
  ╰ Roxygen Arguments (roxygen-arguments): no findings
74
74
  ╰ No Leaked Credentials (no-leaked-credentials): no findings
75
75
  ╰ Undefined Symbol (undefined-symbol): no findings
76
- All queries together required ≈6 ms (1ms accuracy, total 6 ms)
76
+ All queries together required ≈9 ms (1ms accuracy, total 10 ms)
77
77
  ```
78
78
 
79
79
 
@@ -95,12 +95,12 @@ It offers a wide variety of features, for example:
95
95
 
96
96
  _Results (prettified and summarized):_
97
97
 
98
- Query: **linter** (6 ms)\
98
+ Query: **linter** (252 ms)\
99
99
     ╰ **Deprecated Functions** (deprecated-functions): _no findings_\
100
100
     ╰ **File Path Validity** (file-path-validity):\
101
101
         ╰ certain:\
102
102
             ╰ Path `/root/x.txt` at 1.1-23\
103
-        ╰ _Metadata_: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 1, processTimeMs: 0\
103
+        ╰ _Metadata_: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 3, processTimeMs: 1\
104
104
     ╰ **Seeded Randomness** (seeded-randomness): _no findings_\
105
105
     ╰ **Absolute Paths** (absolute-file-paths):\
106
106
         ╰ certain:\
@@ -116,11 +116,11 @@ It offers a wide variety of features, for example:
116
116
     ╰ **Roxygen Arguments** (roxygen-arguments): _no findings_\
117
117
     ╰ **No Leaked Credentials** (no-leaked-credentials): _no findings_\
118
118
     ╰ **Undefined Symbol** (undefined-symbol): _no findings_\
119
- _All queries together required ≈6 ms (1ms accuracy, total 7 ms)_
119
+ _All queries together required ≈252 ms (1ms accuracy, total 254 ms)_
120
120
 
121
121
  <details> <summary style="color:gray">Show Detailed Results as Json</summary>
122
122
 
123
- The analysis required _6.6 ms_ (including parsing and normalization and the query) within the generation environment.
123
+ The analysis required _253.8 ms_ (including parsing and normalization and the query) within the generation environment.
124
124
 
125
125
  In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR.
126
126
  Please consult the [Interface](https://github.com/flowr-analysis/flowr/wiki/Interface) wiki page for more information on how to get those.
@@ -137,8 +137,8 @@ It offers a wide variety of features, for example:
137
137
  ".meta": {
138
138
  "totalCalls": 0,
139
139
  "totalFunctionDefinitions": 0,
140
- "searchTimeMs": 2,
141
- "processTimeMs": 0
140
+ "searchTimeMs": 52,
141
+ "processTimeMs": 169
142
142
  }
143
143
  },
144
144
  "file-path-validity": {
@@ -160,8 +160,8 @@ It offers a wide variety of features, for example:
160
160
  "totalUnknown": 0,
161
161
  "totalWritesBeforeAlways": 0,
162
162
  "totalValid": 0,
163
- "searchTimeMs": 1,
164
- "processTimeMs": 0
163
+ "searchTimeMs": 3,
164
+ "processTimeMs": 1
165
165
  }
166
166
  },
167
167
  "seeded-randomness": {
@@ -172,7 +172,7 @@ It offers a wide variety of features, for example:
172
172
  "callsWithAssignmentProducers": 0,
173
173
  "callsWithNonConstantProducers": 0,
174
174
  "callsWithOtherBranchProducers": 0,
175
- "searchTimeMs": 0,
175
+ "searchTimeMs": 1,
176
176
  "processTimeMs": 0
177
177
  }
178
178
  },
@@ -201,7 +201,7 @@ It offers a wide variety of features, for example:
201
201
  ".meta": {
202
202
  "totalConsidered": 0,
203
203
  "searchTimeMs": 0,
204
- "processTimeMs": 0
204
+ "processTimeMs": 1
205
205
  }
206
206
  },
207
207
  "network-functions": {
@@ -210,7 +210,7 @@ It offers a wide variety of features, for example:
210
210
  "totalCalls": 0,
211
211
  "totalFunctionDefinitions": 0,
212
212
  "searchTimeMs": 0,
213
- "processTimeMs": 0
213
+ "processTimeMs": 1
214
214
  }
215
215
  },
216
216
  "dataframe-access-validation": {
@@ -220,13 +220,13 @@ It offers a wide variety of features, for example:
220
220
  "numAccesses": 0,
221
221
  "totalAccessed": 0,
222
222
  "searchTimeMs": 0,
223
- "processTimeMs": 0
223
+ "processTimeMs": 2
224
224
  }
225
225
  },
226
226
  "dead-code": {
227
227
  "results": [],
228
228
  ".meta": {
229
- "searchTimeMs": 1,
229
+ "searchTimeMs": 0,
230
230
  "processTimeMs": 0
231
231
  }
232
232
  },
@@ -281,16 +281,16 @@ It offers a wide variety of features, for example:
281
281
  "subscript": 0
282
282
  },
283
283
  "searchTimeMs": 0,
284
- "processTimeMs": 1
284
+ "processTimeMs": 20
285
285
  }
286
286
  }
287
287
  },
288
288
  ".meta": {
289
- "timing": 6
289
+ "timing": 252
290
290
  }
291
291
  },
292
292
  ".meta": {
293
- "timing": 6
293
+ "timing": 252
294
294
  }
295
295
  }
296
296
  ```
@@ -354,7 +354,7 @@ It offers a wide variety of features, for example:
354
354
 
355
355
  ```shell
356
356
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
357
- flowR repl v2.13.11, R grammar v14 (tree-sitter engine)
357
+ flowR repl v2.13.12, R grammar v14 (tree-sitter engine)
358
358
  R> :query @static-slice (11@sum) file://test/testfiles/example.R
359
359
  ```
360
360
 
@@ -368,7 +368,7 @@ It offers a wide variety of features, for example:
368
368
  N <- 10
369
369
  for(i in 1:(N-1)) sum <- sum + i + w
370
370
  sum
371
- All queries together required ≈2 ms (1ms accuracy, total 2 ms)
371
+ All queries together required ≈23 ms (1ms accuracy, total 24 ms)
372
372
  ```
373
373
 
374
374
 
@@ -383,7 +383,7 @@ It offers a wide variety of features, for example:
383
383
  </details>
384
384
 
385
385
  * 🚀 **fast call-graph, data-, and control-flow graphs**\
386
- Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">109.6 ms</span></i> (as of Aug 9, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
386
+ Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">81.7 ms</span></i> (as of Aug 10, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
387
387
  _flowR_ can analyze the data- and control-flow of the average real-world R&nbsp;script. See the [benchmarks](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark) for more information,
388
388
  and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph) for more details on the [dataflow graphs](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph) as well as [call graphs](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph#perspectives-cg).
389
389
 
@@ -419,7 +419,7 @@ It offers a wide variety of features, for example:
419
419
 
420
420
  ```shell
421
421
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
422
- flowR repl v2.13.11, R grammar v14 (tree-sitter engine)
422
+ flowR repl v2.13.12, R grammar v14 (tree-sitter engine)
423
423
  R> :dataflow* test/testfiles/example.R
424
424
  ```
425
425
 
@@ -692,7 +692,7 @@ It offers a wide variety of features, for example:
692
692
  ```
693
693
 
694
694
 
695
- (The analysis required _1.7 ms_ (including parse and normalize, using the [tree-sitter](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment. No [signature database](https://github.com/flowr-analysis/flowr/wiki/Signature-Database) is mounted for these generated graphs, so `library()` calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. `acf` as `stats::acf`).)
695
+ (The analysis required _2.6 ms_ (including parse and normalize, using the [tree-sitter](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment. No [signature database](https://github.com/flowr-analysis/flowr/wiki/Signature-Database) is mounted for these generated graphs, so `library()` calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. `acf` as `stats::acf`).)
696
696
 
697
697
 
698
698
 
@@ -873,7 +873,10 @@ please check out the following publications (if you find that a paper is missing
873
873
 
874
874
  ## 🚀 Contributing
875
875
 
876
- We welcome every contribution! Please check out the [developer onboarding](https://github.com/flowr-analysis/flowr/wiki/Onboarding) section in the wiki for all the information you will need.
876
+ We welcome every contribution! The [developer onboarding](https://github.com/flowr-analysis/flowr/wiki/Onboarding) page has everything you need to get started.
877
+ With **R** and **Node.js** installed, `npm run setup:dev` checks your prerequisites, installs the dependencies, and configures the git hooks.
878
+ The [contributing guidelines](https://github.com/flowr-analysis/flowr/tree/main/.github/CONTRIBUTING.md) explain our commit conventions,
879
+ and [Linting and Testing](https://github.com/flowr-analysis/flowr/wiki/Linting-and-Testing) shows how to run the tests.
877
880
 
878
881
  ### Contributors
879
882
 
@@ -0,0 +1,18 @@
1
+ /**
2
+ * A small, fixed, and purely synthetic workload used to calibrate the benchmark results.
3
+ *
4
+ * Publishing its runtime alongside the real measurements allows a viewer to normalize the other numbers by it,
5
+ * and hence to cancel out how fast or how loaded the machine was that produced them.
6
+ * The workload must therefore stay deterministic (no file system, no R session, no randomness)
7
+ * and cheap (well below a second).
8
+ * @module
9
+ */
10
+ /** How often the {@link calibrationRound} is repeated within one {@link runCalibration} call. */
11
+ export declare const CalibrationRounds = 8;
12
+ /** How many elements a single {@link calibrationRound} works on. */
13
+ export declare const CalibrationSize = 4096;
14
+ /**
15
+ * Runs the calibration workload {@link CalibrationRounds} times.
16
+ * @returns a checksum, only returned so that the work cannot be optimized away
17
+ */
18
+ export declare function runCalibration(): number;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ /**
3
+ * A small, fixed, and purely synthetic workload used to calibrate the benchmark results.
4
+ *
5
+ * Publishing its runtime alongside the real measurements allows a viewer to normalize the other numbers by it,
6
+ * and hence to cancel out how fast or how loaded the machine was that produced them.
7
+ * The workload must therefore stay deterministic (no file system, no R session, no randomness)
8
+ * and cheap (well below a second).
9
+ * @module
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CalibrationSize = exports.CalibrationRounds = void 0;
13
+ exports.runCalibration = runCalibration;
14
+ /** How often the {@link calibrationRound} is repeated within one {@link runCalibration} call. */
15
+ exports.CalibrationRounds = 8;
16
+ /** How many elements a single {@link calibrationRound} works on. */
17
+ exports.CalibrationSize = 4096;
18
+ /** xorshift32 with a fixed seed so that every round does the exact same work */
19
+ function nextRandom(state) {
20
+ state ^= state << 13;
21
+ state ^= state >>> 17;
22
+ state ^= state << 5;
23
+ return state | 0;
24
+ }
25
+ /**
26
+ * One round of the calibration workload, mixing integer arithmetic, array sorting, string handling, and map lookups
27
+ * to cover the operations that dominate the analysis itself.
28
+ * @returns a checksum, only returned so that the work cannot be optimized away
29
+ */
30
+ function calibrationRound(round) {
31
+ let state = 0x1337 + round;
32
+ const numbers = new Array(exports.CalibrationSize);
33
+ for (let i = 0; i < exports.CalibrationSize; i++) {
34
+ state = nextRandom(state);
35
+ numbers[i] = state % 100_000;
36
+ }
37
+ numbers.sort((a, b) => a - b);
38
+ const map = new Map();
39
+ for (let i = 0; i < exports.CalibrationSize; i++) {
40
+ const key = `k${numbers[i] % 512}`;
41
+ map.set(key, (map.get(key) ?? 0) + i);
42
+ }
43
+ let checksum = 0;
44
+ for (const [key, value] of map) {
45
+ checksum = (checksum + key.length * value) | 0;
46
+ }
47
+ for (let i = 0; i < exports.CalibrationSize; i++) {
48
+ checksum = (checksum + Math.floor(Math.sqrt(numbers[i] + 1))) | 0;
49
+ }
50
+ return checksum;
51
+ }
52
+ /**
53
+ * Runs the calibration workload {@link CalibrationRounds} times.
54
+ * @returns a checksum, only returned so that the work cannot be optimized away
55
+ */
56
+ function runCalibration() {
57
+ let checksum = 0;
58
+ for (let round = 0; round < exports.CalibrationRounds; round++) {
59
+ checksum = (checksum + calibrationRound(round)) | 0;
60
+ }
61
+ return checksum;
62
+ }
63
+ //# sourceMappingURL=calibration.js.map
@@ -56,8 +56,12 @@ export declare class BenchmarkSlicer {
56
56
  private readonly commonMeasurements;
57
57
  private readonly perSliceMeasurements;
58
58
  private readonly deltas;
59
+ /** filled by {@link measureAdditionalPhases}, only holds the phases that did not fail */
60
+ private readonly additionalMeasurements;
59
61
  private readonly parserName;
60
62
  private context;
63
+ private config;
64
+ private request;
61
65
  private stats;
62
66
  private loadedXml;
63
67
  private dataflow;
@@ -91,6 +95,21 @@ export declare class BenchmarkSlicer {
91
95
  * @returns The statistics of the data frame shape inference
92
96
  */
93
97
  inferDataFrameShapes(): SlicerStatsDfShape;
98
+ /**
99
+ * Measure the phases that are not part of the slicing itself: the dependencies query, the linter,
100
+ * and the synthetic {@link runCalibration | calibration} workload.
101
+ *
102
+ * These run *after* all other steps and are excluded from the {@link CommonSlicerMeasurements} (and hence from
103
+ * the `total`), so that they cannot distort any of the existing measurements.
104
+ * A failing phase is logged and skipped, it never aborts the benchmark.
105
+ */
106
+ measureAdditionalPhases(): Promise<void>;
107
+ /**
108
+ * The additional phases work on the analyzer api, so we have to set up an analyzer for the same request.
109
+ * All of its analyses happen before the measurement starts.
110
+ */
111
+ private buildAnalyzerForAdditionalPhases;
112
+ private measureAdditional;
94
113
  private getInferredRange;
95
114
  private getInferredNumber;
96
115
  /** Bridging the gap between the new internal and the old names for the benchmarking */
@@ -32,6 +32,8 @@ const flowr_analyzer_context_1 = require("../project/context/flowr-analyzer-cont
32
32
  const r_project_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-project");
33
33
  const r_comment_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-comment");
34
34
  const call_graph_1 = require("../dataflow/graph/call-graph");
35
+ const flowr_analyzer_builder_1 = require("../project/flowr-analyzer-builder");
36
+ const calibration_1 = require("./calibration");
35
37
  /**
36
38
  * The logger to be used for benchmarking as a global object.
37
39
  */
@@ -41,8 +43,12 @@ class BenchmarkSlicer {
41
43
  commonMeasurements = new stopwatch_1.Measurements();
42
44
  perSliceMeasurements = new Map();
43
45
  deltas = new Map();
46
+ /** filled by {@link measureAdditionalPhases}, only holds the phases that did not fail */
47
+ additionalMeasurements = new Map();
44
48
  parserName;
45
49
  context;
50
+ config;
51
+ request;
46
52
  stats;
47
53
  loadedXml;
48
54
  dataflow;
@@ -74,6 +80,8 @@ class BenchmarkSlicer {
74
80
  return new tree_sitter_executor_1.TreeSitterExecutor();
75
81
  }
76
82
  });
83
+ this.config = config;
84
+ this.request = request;
77
85
  this.context = (0, flowr_analyzer_context_1.contextFromInput)({ ...request }, config);
78
86
  this.executor = (0, default_pipelines_1.createSlicePipeline)(this.parser, {
79
87
  context: this.context,
@@ -149,6 +157,7 @@ class BenchmarkSlicer {
149
157
  const nonWhitespace = (0, strings_1.withoutWhitespace)(loadedContent).length;
150
158
  this.stats = {
151
159
  perSliceMeasurements: this.perSliceMeasurements,
160
+ additionalMeasurements: this.additionalMeasurements,
152
161
  memory: this.deltas,
153
162
  request,
154
163
  input: {
@@ -175,7 +184,11 @@ class BenchmarkSlicer {
175
184
  retrieveTimePerToken: { raw: 0, normalized: 0 },
176
185
  normalizeTimePerToken: { raw: 0, normalized: 0 },
177
186
  dataflowTimePerToken: { raw: 0, normalized: 0 },
178
- totalCommonTimePerToken: { raw: 0, normalized: 0 }
187
+ totalCommonTimePerToken: { raw: 0, normalized: 0 },
188
+ retrieveTimePer100Lines: 0,
189
+ normalizeTimePer100Lines: 0,
190
+ dataflowTimePer100Lines: 0,
191
+ totalCommonTimePer100Lines: 0
179
192
  };
180
193
  }
181
194
  /**
@@ -233,6 +246,13 @@ class BenchmarkSlicer {
233
246
  (0, assert_1.guard)(this.normalizedAst !== undefined, 'normalizedAst should be defined for control flow extraction');
234
247
  const ast = this.normalizedAst;
235
248
  this.controlFlow = this.measureSimpleStep('extract control flow graph', () => (0, extract_cfg_1.extractCfg)(ast, this.context, undefined, undefined, true));
249
+ if (this.stats) {
250
+ this.stats.controlFlow = {
251
+ numberOfVertices: this.controlFlow.graph.vertices(true).size,
252
+ numberOfEdges: [...this.controlFlow.graph.edges().values()].reduce((a, e) => a + e.size, 0),
253
+ sizeOfObject: (0, size_of_1.getSizeOfCfGraph)(this.controlFlow.graph)
254
+ };
255
+ }
236
256
  }
237
257
  extractCG() {
238
258
  exports.benchmarkLogger.trace('try to extract the call graph');
@@ -322,6 +342,63 @@ class BenchmarkSlicer {
322
342
  this.stats.dataFrameShape = stats;
323
343
  return stats;
324
344
  }
345
+ /**
346
+ * Measure the phases that are not part of the slicing itself: the dependencies query, the linter,
347
+ * and the synthetic {@link runCalibration | calibration} workload.
348
+ *
349
+ * These run *after* all other steps and are excluded from the {@link CommonSlicerMeasurements} (and hence from
350
+ * the `total`), so that they cannot distort any of the existing measurements.
351
+ * A failing phase is logged and skipped, it never aborts the benchmark.
352
+ */
353
+ async measureAdditionalPhases() {
354
+ this.totalStopwatch.pause();
355
+ try {
356
+ this.guardActive();
357
+ const analyzer = await this.buildAnalyzerForAdditionalPhases();
358
+ if (analyzer !== undefined) {
359
+ await this.measureAdditional('dependencies query', () => analyzer.query([{ type: 'dependencies' }]));
360
+ await this.measureAdditional('linter run', () => analyzer.query([{ type: 'linter' }]));
361
+ }
362
+ await this.measureAdditional('calibration', () => (0, calibration_1.runCalibration)());
363
+ }
364
+ catch (e) {
365
+ exports.benchmarkLogger.error(`failed to measure the additional phases: ${e instanceof Error ? e.message : String(e)}`);
366
+ }
367
+ finally {
368
+ this.totalStopwatch.resume();
369
+ }
370
+ }
371
+ /**
372
+ * The additional phases work on the analyzer api, so we have to set up an analyzer for the same request.
373
+ * All of its analyses happen before the measurement starts.
374
+ */
375
+ async buildAnalyzerForAdditionalPhases() {
376
+ try {
377
+ (0, assert_1.guard)(this.config !== undefined && this.request !== undefined, 'need to call init before the additional phases');
378
+ const analyzer = new flowr_analyzer_builder_1.FlowrAnalyzerBuilder()
379
+ .setParser(this.parser)
380
+ .setConfig(this.config)
381
+ .buildSync();
382
+ analyzer.addRequest({ ...this.request });
383
+ await analyzer.runFull();
384
+ return analyzer;
385
+ }
386
+ catch (e) {
387
+ exports.benchmarkLogger.error(`failed to set up the analyzer for the additional phases: ${e instanceof Error ? e.message : String(e)}`);
388
+ return undefined;
389
+ }
390
+ }
391
+ async measureAdditional(keyToMeasure, measurement) {
392
+ const start = process.hrtime.bigint();
393
+ try {
394
+ await measurement();
395
+ }
396
+ catch (e) {
397
+ exports.benchmarkLogger.error(`failed to measure '${keyToMeasure}': ${e instanceof Error ? e.message : String(e)}`);
398
+ return;
399
+ }
400
+ this.additionalMeasurements.set(keyToMeasure, process.hrtime.bigint() - start);
401
+ }
325
402
  getInferredRange(value) {
326
403
  if (value.isValue()) {
327
404
  if (value instanceof set_range_domain_1.SetRangeDomain) {
@@ -463,6 +540,12 @@ class BenchmarkSlicer {
463
540
  raw: dataFrameShapeTime / this.stats.input.numberOfRTokens,
464
541
  normalized: dataFrameShapeTime / this.stats.input.numberOfNormalizedTokens,
465
542
  };
543
+ const per100Lines = 100 / this.stats.input.numberOfLines;
544
+ this.stats.retrieveTimePer100Lines = retrieveTime * per100Lines;
545
+ this.stats.normalizeTimePer100Lines = normalizeTime * per100Lines;
546
+ this.stats.dataflowTimePer100Lines = dataflowTime * per100Lines;
547
+ this.stats.totalCommonTimePer100Lines = (retrieveTime + normalizeTime + dataflowTime) * per100Lines;
548
+ this.stats.controlFlowTimePer100Lines = Number.isNaN(controlFlowTime) ? undefined : controlFlowTime * per100Lines;
466
549
  return {
467
550
  stats: this.stats,
468
551
  parse: typeof this.loadedXml === 'string' ? this.loadedXml : JSON.stringify(this.loadedXml),
@@ -0,0 +1,6 @@
1
+ import type { FlowrFeatureCounts } from './stats';
2
+ /**
3
+ * Counts the linting rules, their tags, the queries, and the built-in definitions by the handler they use.
4
+ * Every count is defensive, as this also runs against older definitions when the history is filled in.
5
+ */
6
+ export declare function countFeatures(): FlowrFeatureCounts;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.countFeatures = countFeatures;
4
+ /**
5
+ * Counts what the running flowR version carries, so a release also shows how the feature set grew.
6
+ * @module
7
+ */
8
+ /* the query module has to come first, the linter rules import back into it */
9
+ const query_1 = require("../../queries/query");
10
+ const linter_rules_1 = require("../../linter/linter-rules");
11
+ const default_builtin_config_1 = require("../../dataflow/environments/default-builtin-config");
12
+ const built_in_proc_name_1 = require("../../dataflow/environments/built-in-proc-name");
13
+ const DefaultProcessors = [built_in_proc_name_1.BuiltInProcName.Default, built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs];
14
+ /** how many linting rules carry each tag, a rule usually carries several */
15
+ function countRuleTags() {
16
+ const tags = {};
17
+ for (const rule of Object.values(linter_rules_1.LintingRules ?? {})) {
18
+ const own = rule?.info?.tags;
19
+ if (!Array.isArray(own)) {
20
+ continue;
21
+ }
22
+ for (const tag of own) {
23
+ if (typeof tag === 'string') {
24
+ tags[tag] = (tags[tag] ?? 0) + 1;
25
+ }
26
+ }
27
+ }
28
+ return tags;
29
+ }
30
+ /**
31
+ * Counts the linting rules, their tags, the queries, and the built-in definitions by the handler they use.
32
+ * Every count is defensive, as this also runs against older definitions when the history is filled in.
33
+ */
34
+ function countFeatures() {
35
+ const builtins = (Array.isArray(default_builtin_config_1.DefaultBuiltinConfig) ? default_builtin_config_1.DefaultBuiltinConfig : []);
36
+ let def = 0, custom = 0, evals = 0;
37
+ for (const entry of builtins) {
38
+ const processor = entry?.processor;
39
+ if (typeof processor === 'string') {
40
+ if (DefaultProcessors.includes(processor)) {
41
+ def++;
42
+ }
43
+ else {
44
+ custom++;
45
+ }
46
+ }
47
+ if (entry?.evalHandler !== undefined) {
48
+ evals++;
49
+ }
50
+ }
51
+ return {
52
+ lintingRules: Object.keys(linter_rules_1.LintingRules ?? {}).length,
53
+ queries: Object.keys(query_1.SupportedQueries ?? {}).length,
54
+ builtinDefinitions: builtins.length,
55
+ builtinDefinitionsDefault: def,
56
+ builtinDefinitionsCustom: custom,
57
+ builtinDefinitionsWithEvalHandler: evals,
58
+ lintingRulesByTag: countRuleTags()
59
+ };
60
+ }
61
+ //# sourceMappingURL=feature-counts.js.map
@@ -229,6 +229,26 @@ Dataframe shape inference: ${formatSummarizedTimeMeasure(stats.common
229
229
  Dataframe shape inference per token: ${formatSummarizedTimeMeasure(stats.dataFrameShapeTimePerToken.normalized)}
230
230
  Dataframe shape inference per R token:${formatSummarizedTimeMeasure(stats.dataFrameShapeTimePerToken.raw)}`;
231
231
  }
232
+ result += `
233
+
234
+ Per 100 lines of input:
235
+ AST retrieval: ${formatSummarizedTimeMeasure(stats.retrieveTimePer100Lines)}
236
+ AST normalization: ${formatSummarizedTimeMeasure(stats.normalizeTimePer100Lines)}
237
+ Dataflow creation: ${formatSummarizedTimeMeasure(stats.dataflowTimePer100Lines)}
238
+ Control flow extraction: ${formatSummarizedTimeMeasure(stats.controlFlowTimePer100Lines)}
239
+ Total common: ${formatSummarizedTimeMeasure(stats.totalCommonTimePer100Lines)}
240
+ Slice creation: ${formatSummarizedTimeMeasure(stats.sliceTimePer100Lines)}
241
+ Reconstruction: ${formatSummarizedTimeMeasure(stats.reconstructTimePer100Lines)}
242
+ Total per slice: ${formatSummarizedTimeMeasure(stats.totalPerSliceTimePer100Lines)}`;
243
+ if (stats.additionalMeasurements !== undefined && stats.additionalMeasurements.size > 0) {
244
+ result += `
245
+
246
+ Additional phases (not part of the total):`;
247
+ for (const [name, measure] of stats.additionalMeasurements) {
248
+ result += `
249
+ ${name.padEnd(34, ' ')}${formatSummarizedTimeMeasure(measure)}`;
250
+ }
251
+ }
232
252
  // Used Slice Criteria Sizes: ${formatSummarizedMeasure(stats.perSliceMeasurements.sliceCriteriaSizes)}
233
253
  if (stats.totalSlices > 0) {
234
254
  result += `
@@ -0,0 +1,7 @@
1
+ import type { SigDbCounts } from './stats';
2
+ /**
3
+ * Counts the bundles of the mounted signature database, what they describe, and what they occupy.
4
+ * Every step is defensive, as this also runs against older databases when the history is filled in, and a
5
+ * machine without a mounted database simply yields `undefined` instead of failing the benchmark.
6
+ */
7
+ export declare function countSignatureDatabase(): Promise<SigDbCounts | undefined>;