@eagleoutice/flowr 1.4.2 → 1.5.0

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 (223) hide show
  1. package/core/print/slice-diff-ansi.js +7 -7
  2. package/core/steps.d.ts +352 -11
  3. package/core/steps.js +4 -4
  4. package/index.d.ts +0 -2
  5. package/index.js +0 -2
  6. package/package.json +65 -215
  7. package/util/{summarizer/summarizer.d.ts → summarizer.d.ts} +15 -1
  8. package/util/summarizer.js +37 -0
  9. package/util/version.d.ts +2 -0
  10. package/util/version.js +10 -0
  11. package/benchmark/index.d.ts +0 -3
  12. package/benchmark/index.js +0 -20
  13. package/benchmark/slicer.d.ts +0 -98
  14. package/benchmark/slicer.js +0 -213
  15. package/benchmark/stats/index.d.ts +0 -10
  16. package/benchmark/stats/index.js +0 -27
  17. package/benchmark/stats/print.d.ts +0 -7
  18. package/benchmark/stats/print.js +0 -155
  19. package/benchmark/stats/stats.d.ts +0 -40
  20. package/benchmark/stats/stats.js +0 -6
  21. package/benchmark/stopwatch.d.ts +0 -35
  22. package/benchmark/stopwatch.js +0 -79
  23. package/cli/benchmark-app.d.ts +0 -10
  24. package/cli/benchmark-app.js +0 -67
  25. package/cli/benchmark-helper-app.d.ts +0 -9
  26. package/cli/benchmark-helper-app.js +0 -69
  27. package/cli/common/features.d.ts +0 -3
  28. package/cli/common/features.js +0 -30
  29. package/cli/common/index.d.ts +0 -2
  30. package/cli/common/index.js +0 -19
  31. package/cli/common/options.d.ts +0 -20
  32. package/cli/common/options.js +0 -85
  33. package/cli/common/script.d.ts +0 -21
  34. package/cli/common/script.js +0 -61
  35. package/cli/common/scripts-info.d.ts +0 -25
  36. package/cli/common/scripts-info.js +0 -83
  37. package/cli/export-quads-app.d.ts +0 -7
  38. package/cli/export-quads-app.js +0 -42
  39. package/cli/repl/commands/cfg.d.ts +0 -3
  40. package/cli/repl/commands/cfg.js +0 -37
  41. package/cli/repl/commands/commands.d.ts +0 -13
  42. package/cli/repl/commands/commands.js +0 -142
  43. package/cli/repl/commands/dataflow.d.ts +0 -3
  44. package/cli/repl/commands/dataflow.js +0 -34
  45. package/cli/repl/commands/execute.d.ts +0 -4
  46. package/cli/repl/commands/execute.js +0 -27
  47. package/cli/repl/commands/index.d.ts +0 -2
  48. package/cli/repl/commands/index.js +0 -19
  49. package/cli/repl/commands/main.d.ts +0 -39
  50. package/cli/repl/commands/main.js +0 -14
  51. package/cli/repl/commands/normalize.d.ts +0 -3
  52. package/cli/repl/commands/normalize.js +0 -34
  53. package/cli/repl/commands/parse.d.ts +0 -2
  54. package/cli/repl/commands/parse.js +0 -109
  55. package/cli/repl/commands/quit.d.ts +0 -2
  56. package/cli/repl/commands/quit.js +0 -15
  57. package/cli/repl/commands/version.d.ts +0 -16
  58. package/cli/repl/commands/version.js +0 -33
  59. package/cli/repl/core.d.ts +0 -41
  60. package/cli/repl/core.js +0 -172
  61. package/cli/repl/execute.d.ts +0 -28
  62. package/cli/repl/execute.js +0 -79
  63. package/cli/repl/index.d.ts +0 -5
  64. package/cli/repl/index.js +0 -22
  65. package/cli/repl/prompt.d.ts +0 -2
  66. package/cli/repl/prompt.js +0 -9
  67. package/cli/repl/server/connection.d.ts +0 -21
  68. package/cli/repl/server/connection.js +0 -213
  69. package/cli/repl/server/messages/analysis.d.ts +0 -71
  70. package/cli/repl/server/messages/analysis.js +0 -21
  71. package/cli/repl/server/messages/error.d.ts +0 -11
  72. package/cli/repl/server/messages/error.js +0 -3
  73. package/cli/repl/server/messages/hello.d.ts +0 -20
  74. package/cli/repl/server/messages/hello.js +0 -3
  75. package/cli/repl/server/messages/index.d.ts +0 -1
  76. package/cli/repl/server/messages/index.js +0 -3
  77. package/cli/repl/server/messages/messages.d.ts +0 -35
  78. package/cli/repl/server/messages/messages.js +0 -40
  79. package/cli/repl/server/messages/repl.d.ts +0 -33
  80. package/cli/repl/server/messages/repl.js +0 -37
  81. package/cli/repl/server/messages/slice.d.ts +0 -25
  82. package/cli/repl/server/messages/slice.js +0 -37
  83. package/cli/repl/server/net.d.ts +0 -49
  84. package/cli/repl/server/net.js +0 -63
  85. package/cli/repl/server/send.d.ts +0 -4
  86. package/cli/repl/server/send.js +0 -18
  87. package/cli/repl/server/server.d.ts +0 -20
  88. package/cli/repl/server/server.js +0 -66
  89. package/cli/repl/server/validate.d.ts +0 -15
  90. package/cli/repl/server/validate.js +0 -34
  91. package/cli/slicer-app.d.ts +0 -11
  92. package/cli/slicer-app.js +0 -81
  93. package/cli/statistics-app.d.ts +0 -11
  94. package/cli/statistics-app.js +0 -98
  95. package/cli/statistics-helper-app.d.ts +0 -11
  96. package/cli/statistics-helper-app.js +0 -82
  97. package/cli/summarizer-app.d.ts +0 -18
  98. package/cli/summarizer-app.js +0 -66
  99. package/flowr.d.ts +0 -29
  100. package/flowr.js +0 -142
  101. package/statistics/features/common-syntax-probability.d.ts +0 -31
  102. package/statistics/features/common-syntax-probability.js +0 -156
  103. package/statistics/features/feature.d.ts +0 -175
  104. package/statistics/features/feature.js +0 -30
  105. package/statistics/features/index.d.ts +0 -1
  106. package/statistics/features/index.js +0 -18
  107. package/statistics/features/post-processing.d.ts +0 -12
  108. package/statistics/features/post-processing.js +0 -21
  109. package/statistics/features/supported/assignments/assignments.d.ts +0 -11
  110. package/statistics/features/supported/assignments/assignments.js +0 -53
  111. package/statistics/features/supported/assignments/index.d.ts +0 -1
  112. package/statistics/features/supported/assignments/index.js +0 -6
  113. package/statistics/features/supported/assignments/post-process.d.ts +0 -3
  114. package/statistics/features/supported/assignments/post-process.js +0 -125
  115. package/statistics/features/supported/comments/comments.d.ts +0 -18
  116. package/statistics/features/supported/comments/comments.js +0 -133
  117. package/statistics/features/supported/comments/index.d.ts +0 -1
  118. package/statistics/features/supported/comments/index.js +0 -6
  119. package/statistics/features/supported/comments/post-process.d.ts +0 -3
  120. package/statistics/features/supported/comments/post-process.js +0 -50
  121. package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
  122. package/statistics/features/supported/control-flow/control-flow.js +0 -67
  123. package/statistics/features/supported/control-flow/index.d.ts +0 -1
  124. package/statistics/features/supported/control-flow/index.js +0 -6
  125. package/statistics/features/supported/control-flow/post-process.d.ts +0 -3
  126. package/statistics/features/supported/control-flow/post-process.js +0 -65
  127. package/statistics/features/supported/data-access/data-access.d.ts +0 -15
  128. package/statistics/features/supported/data-access/data-access.js +0 -118
  129. package/statistics/features/supported/data-access/index.d.ts +0 -1
  130. package/statistics/features/supported/data-access/index.js +0 -6
  131. package/statistics/features/supported/data-access/post-process.d.ts +0 -3
  132. package/statistics/features/supported/data-access/post-process.js +0 -107
  133. package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -35
  134. package/statistics/features/supported/defined-functions/defined-functions.js +0 -139
  135. package/statistics/features/supported/defined-functions/index.d.ts +0 -1
  136. package/statistics/features/supported/defined-functions/index.js +0 -6
  137. package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
  138. package/statistics/features/supported/defined-functions/post-process.js +0 -177
  139. package/statistics/features/supported/expression-list/expression-list.d.ts +0 -9
  140. package/statistics/features/supported/expression-list/expression-list.js +0 -36
  141. package/statistics/features/supported/expression-list/index.d.ts +0 -1
  142. package/statistics/features/supported/expression-list/index.js +0 -6
  143. package/statistics/features/supported/expression-list/post-process.d.ts +0 -3
  144. package/statistics/features/supported/expression-list/post-process.js +0 -44
  145. package/statistics/features/supported/index.d.ts +0 -10
  146. package/statistics/features/supported/index.js +0 -27
  147. package/statistics/features/supported/loops/index.d.ts +0 -1
  148. package/statistics/features/supported/loops/index.js +0 -6
  149. package/statistics/features/supported/loops/loops.d.ts +0 -20
  150. package/statistics/features/supported/loops/loops.js +0 -79
  151. package/statistics/features/supported/loops/post-process.d.ts +0 -3
  152. package/statistics/features/supported/loops/post-process.js +0 -72
  153. package/statistics/features/supported/used-functions/index.d.ts +0 -1
  154. package/statistics/features/supported/used-functions/index.js +0 -6
  155. package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
  156. package/statistics/features/supported/used-functions/post-process.js +0 -179
  157. package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
  158. package/statistics/features/supported/used-functions/used-functions.js +0 -95
  159. package/statistics/features/supported/used-packages/index.d.ts +0 -1
  160. package/statistics/features/supported/used-packages/index.js +0 -6
  161. package/statistics/features/supported/used-packages/post-process.d.ts +0 -3
  162. package/statistics/features/supported/used-packages/post-process.js +0 -121
  163. package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
  164. package/statistics/features/supported/used-packages/used-packages.js +0 -130
  165. package/statistics/features/supported/values/index.d.ts +0 -1
  166. package/statistics/features/supported/values/index.js +0 -6
  167. package/statistics/features/supported/values/post-process.d.ts +0 -3
  168. package/statistics/features/supported/values/post-process.js +0 -72
  169. package/statistics/features/supported/values/values.d.ts +0 -14
  170. package/statistics/features/supported/values/values.js +0 -101
  171. package/statistics/features/supported/variables/index.d.ts +0 -1
  172. package/statistics/features/supported/variables/index.js +0 -6
  173. package/statistics/features/supported/variables/post-process.d.ts +0 -9
  174. package/statistics/features/supported/variables/post-process.js +0 -122
  175. package/statistics/features/supported/variables/variables.d.ts +0 -15
  176. package/statistics/features/supported/variables/variables.js +0 -70
  177. package/statistics/index.d.ts +0 -6
  178. package/statistics/index.js +0 -24
  179. package/statistics/meta-statistics.d.ts +0 -33
  180. package/statistics/meta-statistics.js +0 -17
  181. package/statistics/output/file-provider.d.ts +0 -37
  182. package/statistics/output/file-provider.js +0 -97
  183. package/statistics/output/index.d.ts +0 -4
  184. package/statistics/output/index.js +0 -21
  185. package/statistics/output/print-stats.d.ts +0 -17
  186. package/statistics/output/print-stats.js +0 -69
  187. package/statistics/output/statistics-file.d.ts +0 -37
  188. package/statistics/output/statistics-file.js +0 -69
  189. package/statistics/statistics.d.ts +0 -24
  190. package/statistics/statistics.js +0 -108
  191. package/util/summarizer/auto-detect.d.ts +0 -2
  192. package/util/summarizer/auto-detect.js +0 -32
  193. package/util/summarizer/benchmark/data.d.ts +0 -66
  194. package/util/summarizer/benchmark/data.js +0 -13
  195. package/util/summarizer/benchmark/first-phase/input.d.ts +0 -3
  196. package/util/summarizer/benchmark/first-phase/input.js +0 -75
  197. package/util/summarizer/benchmark/first-phase/process.d.ts +0 -11
  198. package/util/summarizer/benchmark/first-phase/process.js +0 -217
  199. package/util/summarizer/benchmark/second-phase/graph.d.ts +0 -2
  200. package/util/summarizer/benchmark/second-phase/graph.js +0 -54
  201. package/util/summarizer/benchmark/second-phase/process.d.ts +0 -6
  202. package/util/summarizer/benchmark/second-phase/process.js +0 -126
  203. package/util/summarizer/benchmark/summarizer.d.ts +0 -31
  204. package/util/summarizer/benchmark/summarizer.js +0 -58
  205. package/util/summarizer/statistics/first-phase/process.d.ts +0 -6
  206. package/util/summarizer/statistics/first-phase/process.js +0 -81
  207. package/util/summarizer/statistics/post-process/clusterer.d.ts +0 -26
  208. package/util/summarizer/statistics/post-process/clusterer.js +0 -43
  209. package/util/summarizer/statistics/post-process/file-based-count.d.ts +0 -17
  210. package/util/summarizer/statistics/post-process/file-based-count.js +0 -49
  211. package/util/summarizer/statistics/post-process/histogram.d.ts +0 -59
  212. package/util/summarizer/statistics/post-process/histogram.js +0 -128
  213. package/util/summarizer/statistics/post-process/index.d.ts +0 -4
  214. package/util/summarizer/statistics/post-process/index.js +0 -21
  215. package/util/summarizer/statistics/post-process/post-process-output.d.ts +0 -16
  216. package/util/summarizer/statistics/post-process/post-process-output.js +0 -103
  217. package/util/summarizer/statistics/second-phase/process.d.ts +0 -11
  218. package/util/summarizer/statistics/second-phase/process.js +0 -117
  219. package/util/summarizer/statistics/summarizer.d.ts +0 -35
  220. package/util/summarizer/statistics/summarizer.js +0 -135
  221. package/util/summarizer/summarizer.js +0 -13
  222. /package/{statistics/output → util}/ansi.d.ts +0 -0
  223. /package/{statistics/output → util}/ansi.js +0 -0
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./print-stats"), exports);
18
- __exportStar(require("./file-provider"), exports);
19
- __exportStar(require("./statistics-file"), exports);
20
- __exportStar(require("./ansi"), exports);
21
- //# sourceMappingURL=index.js.map
@@ -1,17 +0,0 @@
1
- import type { FeatureKey, FeatureStatistics } from '../features';
2
- import type { MetaStatistics } from '../meta-statistics';
3
- interface MinMaxAvgMedian {
4
- sum: number;
5
- min: number;
6
- max: number;
7
- avg: number;
8
- median: number;
9
- }
10
- export declare function minMaxAvgAndMedian(data: number[]): MinMaxAvgMedian;
11
- export declare function statsString(data: MinMaxAvgMedian, suffix?: string): string;
12
- export declare function printFeatureStatistics(statistics: {
13
- features: FeatureStatistics;
14
- meta: MetaStatistics;
15
- }, features?: 'all' | Set<FeatureKey>): void;
16
- export declare function printFeatureStatisticsEntry(info: Record<string, unknown>): void;
17
- export {};
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.printFeatureStatisticsEntry = exports.printFeatureStatistics = exports.statsString = exports.minMaxAvgAndMedian = void 0;
4
- const features_1 = require("../features");
5
- const ansi_1 = require("./ansi");
6
- const json_1 = require("../../util/json");
7
- function minMaxAvgAndMedian(data) {
8
- data = data.sort((a, b) => a - b);
9
- const sum = data.reduce((a, b) => a + b, 0);
10
- return {
11
- sum,
12
- min: data[0],
13
- max: data[data.length - 1],
14
- avg: sum / data.length,
15
- median: data[Math.floor(data.length / 2)]
16
- };
17
- }
18
- exports.minMaxAvgAndMedian = minMaxAvgAndMedian;
19
- function formatStatNumber(num) {
20
- return num === undefined ? '<?>' : Number(num.toFixed(3)).toLocaleString();
21
- }
22
- function statsString(data, suffix = '') {
23
- return `[${formatStatNumber(data.min)}${suffix} .. ${formatStatNumber(data.max)}${suffix}] (avg: ${formatStatNumber(data.avg)}${suffix}, median: ${formatStatNumber(data.median)}${suffix})`;
24
- }
25
- exports.statsString = statsString;
26
- function printFeatureStatistics(statistics, features = 'all') {
27
- for (const feature of Object.keys(statistics.features)) {
28
- if (features !== 'all' && !features.has(feature)) {
29
- continue;
30
- }
31
- const meta = features_1.ALL_FEATURES[feature];
32
- console.log(`\n\n-----${meta.name}-------------`);
33
- console.log(ansi_1.formatter.format(meta.description, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground }));
34
- printFeatureStatisticsEntry(statistics.features[feature]);
35
- console.log('\n\n');
36
- }
37
- const linesPerFile = minMaxAvgAndMedian(statistics.meta.lines.map(l => l.length));
38
- const lineLengths = minMaxAvgAndMedian(statistics.meta.lines.flat());
39
- const processingTimesPerFile = minMaxAvgAndMedian(statistics.meta.processingTimeMs);
40
- console.log(`processed ${statistics.meta.successfulParsed} files (skipped ${statistics.meta.failedRequests.length} due to errors):
41
- \ttotal processing time: ${processingTimesPerFile.sum} ms
42
- \t\tprocessing time range: ${statsString(processingTimesPerFile, ' ms')}
43
- \ttotal number of lines: ${lineLengths.sum}
44
- \t\tline range: ${statsString(linesPerFile)}
45
- \t\tline length range: ${statsString(lineLengths, ' chars')}
46
- `);
47
- }
48
- exports.printFeatureStatistics = printFeatureStatistics;
49
- const pad = 3;
50
- function printFeatureStatisticsEntry(info) {
51
- let longestKey = 0;
52
- let longestValue = 0;
53
- const out = new Map();
54
- for (const [key, value] of Object.entries(info)) {
55
- if (key.length > longestKey) {
56
- longestKey = key.length;
57
- }
58
- const valueString = JSON.stringify(value, json_1.jsonReplacer);
59
- out.set(key, valueString);
60
- if (valueString.length > longestValue) {
61
- longestValue = valueString.length;
62
- }
63
- }
64
- for (const [key, value] of out.entries()) {
65
- console.log(`${key.padEnd(longestKey + pad)} ${value.padStart(longestValue)}`);
66
- }
67
- }
68
- exports.printFeatureStatisticsEntry = printFeatureStatisticsEntry;
69
- //# sourceMappingURL=print-stats.js.map
@@ -1,37 +0,0 @@
1
- import type { DummyAppendMemoryMap, StatisticAppendProvider } from './file-provider';
2
- /**
3
- * Requires source information to be attached on parsing!
4
- * <p>
5
- * Returns the content of the node (i.e., the text content excluding the children)
6
- */
7
- export declare function extractNodeContent(node: Node): string;
8
- /** by default, we do not write to anything */
9
- export declare let statisticsFileProvider: StatisticAppendProvider;
10
- /**
11
- * Make the statistics write to a given output directory.
12
- */
13
- export declare function initFileProvider(outputDirectory: string): void;
14
- /**
15
- * Either ignore the statistics or write them to a given map (e.g., for testing).
16
- *
17
- * @param map - The map to write to, will not persist calls if no map is given
18
- */
19
- export declare function initDummyFileProvider(map?: DummyAppendMemoryMap): void;
20
- /**
21
- * Format used to dump each entry of a feature during collection.
22
- */
23
- export type StatisticsOutputFormat<T = string> = [
24
- /** the collected value (like the assignment operator lexeme, ...) */
25
- value: T,
26
- /** the context of the information retrieval (e.g. the name of the file that contained the R source code) */
27
- context: string | undefined
28
- ];
29
- /**
30
- * Append the content of all nodes to the storage file for the given feature
31
- * @param name - The name of the feature {@link Feature#name}
32
- * @param fn - The name of the feature-aspect to record
33
- * @param nodes - The nodes to append, you may pass already transformed string contents
34
- * @param context - The context of the information retrieval (e.g. the name of the file that contained the R source code)
35
- * @param unique - Should duplicate entries be removed on addition
36
- */
37
- export declare function appendStatisticsFile<T>(name: string, fn: keyof T, nodes: string[] | Node[] | object[], context: string | undefined, unique?: boolean): void;
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.appendStatisticsFile = exports.initDummyFileProvider = exports.initFileProvider = exports.statisticsFileProvider = exports.extractNodeContent = void 0;
4
- const file_provider_1 = require("./file-provider");
5
- const log_1 = require("../../util/log");
6
- /**
7
- * Requires source information to be attached on parsing!
8
- * <p>
9
- * Returns the content of the node (i.e., the text content excluding the children)
10
- */
11
- function extractNodeContent(node) {
12
- let result = node.textContent;
13
- if (node.hasChildNodes()) {
14
- const firstChild = node.childNodes.item(0);
15
- if (firstChild.nodeType === 3 /* text node */) {
16
- result = firstChild.textContent;
17
- }
18
- }
19
- return result?.trim()?.replaceAll('\n', '\\n') ?? '<unknown>';
20
- }
21
- exports.extractNodeContent = extractNodeContent;
22
- initDummyFileProvider();
23
- /**
24
- * Make the statistics write to a given output directory.
25
- */
26
- function initFileProvider(outputDirectory) {
27
- log_1.log.debug(`Initializing file provider for output directory ${outputDirectory}`);
28
- exports.statisticsFileProvider = new file_provider_1.StatisticFileProvider(outputDirectory);
29
- }
30
- exports.initFileProvider = initFileProvider;
31
- /**
32
- * Either ignore the statistics or write them to a given map (e.g., for testing).
33
- *
34
- * @param map - The map to write to, will not persist calls if no map is given
35
- */
36
- function initDummyFileProvider(map) {
37
- exports.statisticsFileProvider = new file_provider_1.DummyAppendProvider(map);
38
- }
39
- exports.initDummyFileProvider = initDummyFileProvider;
40
- /**
41
- * Append the content of all nodes to the storage file for the given feature
42
- * @param name - The name of the feature {@link Feature#name}
43
- * @param fn - The name of the feature-aspect to record
44
- * @param nodes - The nodes to append, you may pass already transformed string contents
45
- * @param context - The context of the information retrieval (e.g. the name of the file that contained the R source code)
46
- * @param unique - Should duplicate entries be removed on addition
47
- */
48
- function appendStatisticsFile(name, fn, nodes, context, unique = false) {
49
- if (nodes.length === 0) {
50
- return;
51
- }
52
- let values;
53
- if (typeof nodes[0] === 'string') {
54
- values = nodes;
55
- }
56
- else if ('nodeType' in nodes[0]) {
57
- values = nodes.map(extractNodeContent);
58
- }
59
- else {
60
- values = nodes;
61
- }
62
- if (unique) {
63
- values = [...new Set(values)];
64
- }
65
- values = values.map(value => JSON.stringify(context === undefined ? [value] : [value, context]));
66
- exports.statisticsFileProvider.append(name, fn, values.join('\n'));
67
- }
68
- exports.appendStatisticsFile = appendStatisticsFile;
69
- //# sourceMappingURL=statistics-file.js.map
@@ -1,24 +0,0 @@
1
- import type { RParseRequestFromFile, RParseRequestFromText, RShell } from '../r-bridge';
2
- import type { FeatureSelection, FeatureStatistics } from './features';
3
- import type { MetaStatistics } from './meta-statistics';
4
- import type { StepResults } from '../core';
5
- /**
6
- * By default, {@link extractUsageStatistics} requires a generator, but sometimes you already know all the files
7
- * that you want to process. This function simply reps your requests as a generator.
8
- */
9
- export declare function staticRequests(...requests: (RParseRequestFromText | RParseRequestFromFile)[]): AsyncGenerator<RParseRequestFromText | RParseRequestFromFile>;
10
- /**
11
- * Extract all wanted statistic information from a set of requests using the presented R session.
12
- *
13
- * @param shell - The R session to use
14
- * @param onRequest - A callback that is called at the beginning of each request, this may be used to debug the requests.
15
- * @param features - The features to extract (see {@link allFeatureNames}).
16
- * @param requests - The requests to extract the features from. May generate them on demand (e.g., by traversing a folder).
17
- * If your request is statically known, you can use {@link staticRequests} to create this generator.
18
- * @param rootPath - The root path to the project, this is used to relativize the file paths in the statistics.
19
- */
20
- export declare function extractUsageStatistics<T extends RParseRequestFromText | RParseRequestFromFile>(shell: RShell, onRequest: (request: T) => void, features: FeatureSelection, requests: AsyncGenerator<T>, rootPath?: string): Promise<{
21
- features: FeatureStatistics;
22
- meta: MetaStatistics;
23
- outputs: Map<T, StepResults<'dataflow'>>;
24
- }>;
@@ -1,108 +0,0 @@
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.extractUsageStatistics = exports.staticRequests = void 0;
7
- const r_bridge_1 = require("../r-bridge");
8
- const features_1 = require("./features");
9
- const xmldom_1 = require("@xmldom/xmldom");
10
- const fs_1 = __importDefault(require("fs"));
11
- const log_1 = require("../util/log");
12
- const meta_statistics_1 = require("./meta-statistics");
13
- const core_1 = require("../core");
14
- const json_1 = require("../util/json");
15
- /**
16
- * By default, {@link extractUsageStatistics} requires a generator, but sometimes you already know all the files
17
- * that you want to process. This function simply reps your requests as a generator.
18
- */
19
- function staticRequests(...requests) {
20
- // eslint-disable-next-line @typescript-eslint/require-await
21
- return async function* () {
22
- for (const request of requests) {
23
- yield request;
24
- }
25
- }();
26
- }
27
- exports.staticRequests = staticRequests;
28
- /**
29
- * Extract all wanted statistic information from a set of requests using the presented R session.
30
- *
31
- * @param shell - The R session to use
32
- * @param onRequest - A callback that is called at the beginning of each request, this may be used to debug the requests.
33
- * @param features - The features to extract (see {@link allFeatureNames}).
34
- * @param requests - The requests to extract the features from. May generate them on demand (e.g., by traversing a folder).
35
- * If your request is statically known, you can use {@link staticRequests} to create this generator.
36
- * @param rootPath - The root path to the project, this is used to relativize the file paths in the statistics.
37
- */
38
- async function extractUsageStatistics(shell, onRequest, features, requests, rootPath) {
39
- let result = initializeFeatureStatistics();
40
- const meta = (0, meta_statistics_1.initialMetaStatistics)();
41
- const outputs = new Map();
42
- for await (const request of requests) {
43
- onRequest(request);
44
- const start = performance.now();
45
- const suffix = request.request === 'file' ? request.content.replace(new RegExp('^' + (rootPath ?? '')), '') : undefined;
46
- try {
47
- let output;
48
- ({ stats: result, output } = await extractSingle(result, shell, request, features, suffix));
49
- outputs.set(request, output);
50
- processMetaOnSuccessful(meta, request);
51
- meta.numberOfNormalizedNodes.push(output.normalize.idMap.size);
52
- }
53
- catch (e) {
54
- log_1.log.error('for request: ', request, e);
55
- processMetaOnUnsuccessful(meta, request);
56
- }
57
- meta.processingTimeMs.push(performance.now() - start);
58
- }
59
- return { features: result, meta, outputs };
60
- }
61
- exports.extractUsageStatistics = extractUsageStatistics;
62
- function initializeFeatureStatistics() {
63
- const result = {};
64
- for (const key of features_1.allFeatureNames) {
65
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
66
- result[key] = JSON.parse(JSON.stringify(features_1.ALL_FEATURES[key].initialValue, json_1.jsonReplacer), json_1.jsonRetriever);
67
- }
68
- return result;
69
- }
70
- function processMetaOnUnsuccessful(meta, request) {
71
- meta.failedRequests.push(request);
72
- }
73
- function processMetaOnSuccessful(meta, request) {
74
- meta.successfulParsed++;
75
- if (request.request === 'text') {
76
- meta.lines.push(request.content.split('\n').map(l => l.length));
77
- }
78
- else {
79
- meta.lines.push(fs_1.default.readFileSync(request.content, 'utf-8').split('\n').map(l => l.length));
80
- }
81
- }
82
- const parser = new xmldom_1.DOMParser();
83
- async function extractSingle(result, shell, request, features, suffixFilePath) {
84
- const slicerOutput = await new core_1.SteppingSlicer({
85
- stepOfInterest: 'dataflow',
86
- request, shell
87
- }).allRemainingSteps();
88
- // retrieve parsed xml through (legacy) xmlparsedata
89
- const suffix = request.request === 'file' ? ', encoding="utf-8"' : '';
90
- shell.sendCommands(`try(flowr_parsed<-parse(${request.request}=${JSON.stringify(request.content)},keep.source=TRUE${suffix}),silent=FALSE)`, 'try(flowr_output<-xmlparsedata::xml_parse_data(flowr_parsed,includeText=TRUE,pretty=FALSE),silent=FALSE)');
91
- const parsed = (await shell.sendCommandWithOutput(`cat(flowr_output,${(0, r_bridge_1.ts2r)(shell.options.eol)})`)).join(shell.options.eol);
92
- const doc = parser.parseFromString(parsed, 'text/xml');
93
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
94
- for (const [key, feature] of Object.entries(features_1.ALL_FEATURES)) {
95
- if (features !== 'all' && !features.has(key)) {
96
- continue;
97
- }
98
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
99
- result[key] = feature.process(result[key], {
100
- parsedRAst: doc,
101
- dataflow: slicerOutput.dataflow,
102
- normalizedRAst: slicerOutput.normalize,
103
- filepath: suffixFilePath
104
- });
105
- }
106
- return { stats: result, output: slicerOutput };
107
- }
108
- //# sourceMappingURL=statistics.js.map
@@ -1,2 +0,0 @@
1
- import { SummarizerType } from './summarizer';
2
- export declare function detectSummarizationType(inputPath: string): Promise<SummarizerType>;
@@ -1,32 +0,0 @@
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.detectSummarizationType = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const log_1 = require("../log");
9
- const summarizer_1 = require("./statistics/summarizer");
10
- async function detectSummarizationType(inputPath) {
11
- if (fs_1.default.statSync(inputPath).isFile()) {
12
- log_1.log.info(`Detected benchmark summarization with single file ${inputPath}`);
13
- return "benchmark" /* SummarizerType.Benchmark */;
14
- }
15
- // current heuristic: search for a tar.gz with two minus signs :D
16
- const dir = await fs_1.default.promises.opendir(inputPath);
17
- const thresholdInit = 60;
18
- let threshold = thresholdInit;
19
- for await (const dirent of dir) {
20
- if (summarizer_1.statisticsFileNameRegex.test(dirent.name)) {
21
- log_1.log.info(`Detected statistics summarization by file ${dirent.name} matching ${summarizer_1.statisticsFileNameRegex.source}`);
22
- return "statistics" /* SummarizerType.Statistics */;
23
- }
24
- else if (threshold-- < 0) {
25
- break;
26
- }
27
- }
28
- log_1.log.info(`Detected benchmark summarization with no file (first ${thresholdInit}) matching ${summarizer_1.statisticsFileNameRegex.source}`);
29
- return "benchmark" /* SummarizerType.Benchmark */;
30
- }
31
- exports.detectSummarizationType = detectSummarizationType;
32
- //# sourceMappingURL=auto-detect.js.map
@@ -1,66 +0,0 @@
1
- import type { CommonSlicerMeasurements, PerSliceMeasurements, SlicerStats, SlicerStatsDataflow, SlicerStatsInput } from '../../../benchmark';
2
- export interface SummarizedMeasurement<T = number> {
3
- min: T;
4
- max: T;
5
- median: T;
6
- /** total may be useless for some measurements, especially if they are weighted before (it is just the sum...)*/
7
- total: T;
8
- /** average */
9
- mean: number;
10
- /** standard deviation */
11
- std: number;
12
- }
13
- export declare function summarizedMeasurement2Csv(a: SummarizedMeasurement): string;
14
- export declare function summarizedMeasurement2CsvHeader(prefix?: string): string;
15
- export interface SliceSizeCollection {
16
- lines: number[];
17
- characters: number[];
18
- nonWhitespaceCharacters: number[];
19
- /** like library statements during reconstruction */
20
- autoSelected: number[];
21
- dataflowNodes: number[];
22
- tokens: number[];
23
- normalizedTokens: number[];
24
- }
25
- /**
26
- * @see SlicerStats
27
- * @see summarizeSlicerStats
28
- */
29
- export type SummarizedSlicerStats = {
30
- perSliceMeasurements: SummarizedPerSliceStats;
31
- } & Omit<SlicerStats, 'perSliceMeasurements'>;
32
- export interface Reduction<T = number> {
33
- numberOfLines: T;
34
- numberOfLinesNoAutoSelection: T;
35
- numberOfCharacters: T;
36
- numberOfNonWhitespaceCharacters: T;
37
- numberOfRTokens: T;
38
- numberOfNormalizedTokens: T;
39
- numberOfDataflowNodes: T;
40
- }
41
- export interface SummarizedPerSliceStats {
42
- /** number of total slicing calls */
43
- numberOfSlices: number;
44
- /** statistics on the used slicing criteria (number of ids within criteria etc.) */
45
- sliceCriteriaSizes: SummarizedMeasurement;
46
- measurements: Map<PerSliceMeasurements, SummarizedMeasurement>;
47
- reduction: Reduction<SummarizedMeasurement>;
48
- failedToRepParse: number;
49
- timesHitThreshold: number;
50
- sliceSize: {
51
- [K in keyof SliceSizeCollection]: SummarizedMeasurement;
52
- };
53
- }
54
- export interface UltimateSlicerStats {
55
- totalRequests: number;
56
- totalSlices: number;
57
- commonMeasurements: Map<CommonSlicerMeasurements, SummarizedMeasurement>;
58
- perSliceMeasurements: Map<PerSliceMeasurements, SummarizedMeasurement>;
59
- /** sum */
60
- failedToRepParse: number;
61
- /** sum */
62
- timesHitThreshold: number;
63
- reduction: Reduction<SummarizedMeasurement>;
64
- input: SlicerStatsInput<SummarizedMeasurement>;
65
- dataflow: SlicerStatsDataflow<SummarizedMeasurement>;
66
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.summarizedMeasurement2CsvHeader = exports.summarizedMeasurement2Csv = void 0;
4
- function summarizedMeasurement2Csv(a) {
5
- return `${a.min},${a.max},${a.median},${a.mean},${a.std},${a.total}`;
6
- }
7
- exports.summarizedMeasurement2Csv = summarizedMeasurement2Csv;
8
- const summarizedKeys = ['min', 'max', 'median', 'mean', 'std', 'total'];
9
- function summarizedMeasurement2CsvHeader(prefix) {
10
- return summarizedKeys.map(k => prefix ? `${prefix}-${k}` : k).join(',');
11
- }
12
- exports.summarizedMeasurement2CsvHeader = summarizedMeasurement2CsvHeader;
13
- //# sourceMappingURL=data.js.map
@@ -1,3 +0,0 @@
1
- /// <reference types="node" />
2
- export declare function processRunMeasurement(line: Buffer, fileNum: number, lineNum: number, summarizedText: string, outputPath: string): Promise<void>;
3
- export declare function processSummarizedFileMeasurement(file: string, summariesFile: string, outputPath: string): void;
@@ -1,75 +0,0 @@
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.processSummarizedFileMeasurement = exports.processRunMeasurement = void 0;
7
- const benchmark_1 = require("../../../../benchmark");
8
- const assert_1 = require("../../../assert");
9
- const statistics_1 = require("../../../../statistics");
10
- const fs_1 = __importDefault(require("fs"));
11
- const json_1 = require("../../../json");
12
- const files_1 = require("../../../files");
13
- const process_1 = require("../second-phase/process");
14
- async function processRunMeasurement(line, fileNum, lineNum, summarizedText, outputPath) {
15
- let got = JSON.parse(line.toString());
16
- console.log(`[file ${fileNum}, line ${lineNum}] Summarize for ${got.filename}`);
17
- // now we have to recover the maps and bigints :C
18
- got = {
19
- filename: got.filename,
20
- 'file-id': got['file-id'],
21
- 'run-num': got['run-num'],
22
- stats: {
23
- input: got.stats.input,
24
- request: got.stats.request,
25
- dataflow: got.stats.dataflow,
26
- commonMeasurements: new Map(got.stats.commonMeasurements
27
- .map(([k, v]) => {
28
- (0, assert_1.guard)(v.endsWith('n'), 'Expected a bigint');
29
- return [k, BigInt(v.slice(0, -1))];
30
- })),
31
- perSliceMeasurements: new Map(got.stats.perSliceMeasurements
32
- .map(([k, v]) => mapPerSliceStats(k, v)))
33
- }
34
- };
35
- const totalSlices = got.stats.perSliceMeasurements.size;
36
- console.log(`Summarizing ${totalSlices} slices...`);
37
- let atSliceNumber = 0;
38
- const summarized = await (0, benchmark_1.summarizeSlicerStats)(got.stats, (criterion, stats) => {
39
- console.log(`${statistics_1.escape}1F${statistics_1.escape}1G${statistics_1.escape}2K [${++atSliceNumber}/${totalSlices}] Summarizing ${JSON.stringify(criterion)} (reconstructed has ${stats.reconstructedCode.code.length} characters)`);
40
- });
41
- console.log(` - Append raw summary to ${outputPath}`);
42
- fs_1.default.appendFileSync(outputPath, `${JSON.stringify({
43
- filename: got.filename,
44
- 'file-id': got['file-id'],
45
- 'run-num': got['run-num'],
46
- summarize: summarized
47
- }, json_1.jsonReplacer)}\n`);
48
- console.log(` - Append textual summary to ${summarizedText}`);
49
- fs_1.default.appendFileSync(summarizedText, `${(0, benchmark_1.stats2string)(summarized)}\n`);
50
- }
51
- exports.processRunMeasurement = processRunMeasurement;
52
- function processSummarizedFileMeasurement(file, summariesFile, outputPath) {
53
- console.log(`Summarize all runs for ${file}`);
54
- const summaries = [];
55
- (0, files_1.readLineByLineSync)(summariesFile, l => (0, process_1.processNextSummary)(l, summaries));
56
- fs_1.default.appendFileSync(outputPath, `${JSON.stringify({
57
- filename: file,
58
- summarize: (0, process_1.summarizeAllSummarizedStats)(summaries)
59
- }, json_1.jsonReplacer)}\n`);
60
- }
61
- exports.processSummarizedFileMeasurement = processSummarizedFileMeasurement;
62
- function mapPerSliceStats(k, v) {
63
- return [k, {
64
- reconstructedCode: v.reconstructedCode,
65
- slicingCriteria: v.slicingCriteria,
66
- timesHitThreshold: v.timesHitThreshold,
67
- measurements: new Map(v.measurements
68
- .map(([k, v]) => {
69
- (0, assert_1.guard)(v.endsWith('n'), 'Expected a bigint');
70
- return [k, BigInt(v.slice(0, -1))];
71
- })),
72
- numberOfDataflowNodesSliced: v.numberOfDataflowNodesSliced
73
- }];
74
- }
75
- //# sourceMappingURL=input.js.map
@@ -1,11 +0,0 @@
1
- import type { Reduction, SummarizedMeasurement, SummarizedSlicerStats } from '../data';
2
- import type { PerSliceStats, SlicerStats } from '../../../../benchmark';
3
- import type { SlicingCriteria } from '../../../../slicing';
4
- /**
5
- * Summarizes the given stats by calculating the min, max, median, mean, and the standard deviation for each measurement.
6
- * @see Slicer
7
- */
8
- export declare function summarizeSlicerStats(stats: SlicerStats, report?: (criteria: SlicingCriteria, stats: PerSliceStats) => void): Promise<Readonly<SummarizedSlicerStats>>;
9
- export declare function summarizeMeasurement(data: number[], totalNumberOfDataPoints?: number): SummarizedMeasurement;
10
- export declare function summarizeSummarizedMeasurement(data: SummarizedMeasurement[]): SummarizedMeasurement;
11
- export declare function summarizeReductions(reductions: Reduction<SummarizedMeasurement>[]): Reduction<SummarizedMeasurement>;