@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
97 lines (96 loc) • 4.41 kB
TypeScript
import type { SlicingCriterion, SlicingCriteria } from '../../slicing/criterion/parse';
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
import type { ReconstructionResult } from '../../reconstruct/reconstruct';
import type { RParseRequestFromFile, RParseRequestFromText } from '../../r-bridge/retriever';
import type { TimePerToken } from '../summarizer/data';
import type { MergeableRecord } from '../../util/objects';
import type { DataFrameOperationName } from '../../abstract-interpretation/data-frame/semantics';
export declare const RequiredSlicerMeasurements: readonly ["initialize R session", "retrieve AST from R code", "normalize R AST", "produce dataflow information", "close R session", "total"];
export declare const OptionalSlicerMeasurements: readonly ["extract control flow graph", "infer data frame shapes", "extract call graph"];
export declare const CommonSlicerMeasurements: readonly ["initialize R session", "retrieve AST from R code", "normalize R AST", "produce dataflow information", "close R session", "total", "extract control flow graph", "infer data frame shapes", "extract call graph"];
export type CommonSlicerMeasurements = typeof CommonSlicerMeasurements[number];
export declare const PerSliceMeasurements: readonly ["static slicing", "reconstruct code", "total"];
export type PerSliceMeasurements = typeof PerSliceMeasurements[number];
export type ElapsedTime = bigint;
export interface PerSliceStats {
measurements: Map<PerSliceMeasurements, ElapsedTime>;
slicingCriteria: {
criterion: SlicingCriterion;
id: NodeId;
}[];
reconstructedCode: ReconstructionResult;
numberOfDataflowNodesSliced: number;
timesHitThreshold: number;
}
export interface SlicerStatsInput<T = number> {
numberOfLines: T;
numberOfNonEmptyLines: T;
numberOfCharacters: T;
numberOfCharactersNoComments: T;
numberOfNonWhitespaceCharacters: T;
numberOfNonWhitespaceCharactersNoComments: T;
numberOfRTokens: T;
numberOfRTokensNoComments: T;
numberOfNormalizedTokens: T;
numberOfNormalizedTokensNoComments: T;
}
export interface SlicerStatsDataflow<T = number> {
numberOfNodes: T;
numberOfEdges: T;
numberOfCalls: T;
numberOfFunctionDefinitions: T;
sizeOfObject: T;
}
export interface SlicerStatsDfShape<T = number> {
numberOfDataFrameFiles: T extends number ? 0 | 1 : number;
numberOfNonDataFrameFiles: T extends number ? 0 | 1 : number;
numberOfResultConstraints: T;
numberOfResultingValues: T;
numberOfResultingBottom: T;
numberOfResultingTop: T;
numberOfEmptyNodes: T;
numberOfOperationNodes: T;
numberOfValueNodes: T;
sizeOfInfo: T;
perNodeStats: Map<NodeId, PerNodeStatsDfShape<T>>;
}
export interface PerNodeStatsDfShape<T = number> {
numberOfEntries: T;
mappedOperations?: DataFrameOperationName[];
inferredColNames?: T | 'bottom' | 'infinite' | 'top';
inferredColCount?: T | 'bottom' | 'infinite' | 'top';
inferredRowCount?: T | 'bottom' | 'infinite' | 'top';
/** difference between upper and lower bound of interval domain (to estimate approximation) */
approxRangeColNames?: T;
approxRangeColCount?: T;
approxRangeRowCount?: T;
}
/**
* Please note, that these measurement can be negative as there is no guarantee that the memory usage will increase
* due to, e.g., garbage collection.
*/
export interface BenchmarkMemoryMeasurement<T = number> extends MergeableRecord {
heap: T;
rss: T;
external: T;
buffs: T;
}
/**
* The statistics that are collected by the {@link BenchmarkSlicer} and used for benchmarking.
*/
export interface SlicerStats {
commonMeasurements: Map<CommonSlicerMeasurements, ElapsedTime>;
perSliceMeasurements: Map<SlicingCriteria, PerSliceStats>;
memory: Map<CommonSlicerMeasurements, BenchmarkMemoryMeasurement>;
request: RParseRequestFromFile | RParseRequestFromText;
input: SlicerStatsInput;
dataflow: SlicerStatsDataflow;
dataFrameShape?: SlicerStatsDfShape;
retrieveTimePerToken: TimePerToken<number>;
normalizeTimePerToken: TimePerToken<number>;
dataflowTimePerToken: TimePerToken<number>;
totalCommonTimePerToken: TimePerToken<number>;
controlFlowTimePerToken?: TimePerToken<number>;
callGraphTimePerToken?: TimePerToken<number>;
dataFrameShapeTimePerToken?: TimePerToken<number>;
}