@oaklean/profiler-core
Version:
Part of the @oaklean suite. It provides all basic functions to work with the `.oak` file format. It allows parsing the `.oak` file format as well as tools for analyzing the measurement values. It also provides all necessary capabilities required for prec
113 lines (112 loc) • 6.24 kB
TypeScript
import { BaseModel } from './BaseModel';
import { ModelMap } from './ModelMap';
import { NodeModule } from './NodeModule';
import { AggregatedSourceNodeMetaData, SourceFileMetaData } from './SourceFileMetaData';
import { SourceNodeMetaData } from './SourceNodeMetaData';
import { ProfilerConfig } from './ProfilerConfig';
import { SensorValues } from './SensorValues';
import { ModuleIndex } from './indices/ModuleIndex';
import { GlobalIndex } from './indices/GlobalIndex';
import { PathIndex } from './indices/PathIndex';
import { UnifiedPath } from '../system/UnifiedPath';
import { LangInternalPath_string, LangInternalSourceNodeIdentifier_string, SourceNodeIdentifier_string, UnifiedPath_string, SourceNodeMetaDataType, ReportKind, NodeModuleIdentifier_string, ModuleID_number, IndexRequestType, PathID_number, IReport, ReportType, SourceNodeID_number, SourceNodeMetaDataType_Node } from '../types';
export declare class Report extends BaseModel {
reportVersion: string;
kind: ReportKind;
relativeRootDir?: UnifiedPath;
private _headlessSensorValues?;
private _lang_internal?;
private _intern?;
private _extern?;
internID: number;
moduleIndex: ModuleIndex;
constructor(moduleIndex: ModuleIndex, kind: ReportKind);
/**
* Resolve a source node ID to its corresponding source node metadata within this report.
* @param report - The report to which the source node belongs (necessary for lang internal and extern).
* @param globalIndex - The global index of the project report.
* @param sourceNodeID - The unique identifier of the source node to resolve.
* @returns An object containing either the resolved report, source file metadata, and source node metadata,
* or an error indication if the resolution fails.
*/
resolveSourceNodeID(globalIndex: GlobalIndex, sourceNodeID: SourceNodeID_number): {
error: true;
} | {
error: true;
report: ProjectReport | ModuleReport;
} | {
error: true;
report: ProjectReport | ModuleReport;
sourceFileMetaData: SourceFileMetaData;
} | {
error: false;
report: ProjectReport | ModuleReport;
sourceFileMetaData: SourceFileMetaData;
sourceNode: SourceNodeMetaData<SourceNodeMetaDataType_Node>;
};
getSourceFileMetaDataByPathID(pathID: PathID_number): SourceFileMetaData | undefined;
normalize(newGlobalIndex: GlobalIndex): void;
get headlessSensorValues(): SensorValues;
set headlessSensorValues(value: SensorValues);
get lang_internal(): ModelMap<PathID_number, SourceFileMetaData>;
get intern(): ModelMap<PathID_number, SourceFileMetaData>;
get extern(): ModelMap<ModuleID_number, ModuleReport>;
getLangInternalPathIndex<T extends IndexRequestType, R = T extends 'upsert' ? PathIndex : PathIndex | undefined>(indexRequestType: T, filePath: LangInternalPath_string): R;
getModuleIndexByID(id: ModuleID_number): ModuleIndex | undefined;
getModuleIndex<T extends IndexRequestType, R = T extends 'upsert' ? ModuleIndex : ModuleIndex | undefined>(indexRequestType: T, moduleIdentifier: NodeModuleIdentifier_string): R;
getPathIndexByID(id: PathID_number): PathIndex | undefined;
getPathIndex<T extends IndexRequestType, R = T extends 'upsert' ? PathIndex : PathIndex | undefined>(indexRequestType: T, filePath: UnifiedPath_string): R;
addToLangInternal(filePath: LangInternalPath_string, functionIdentifier: LangInternalSourceNodeIdentifier_string): SourceNodeMetaData<SourceNodeMetaDataType.LangInternalSourceNode>;
addToIntern(filePath: UnifiedPath_string, functionIdentifier: SourceNodeIdentifier_string): SourceNodeMetaData<SourceNodeMetaDataType.SourceNode>;
addToExtern(filePath: UnifiedPath, nodeModule: NodeModule, functionIdentifier: SourceNodeIdentifier_string): {
report: ModuleReport;
sourceNodeMetaData: SourceNodeMetaData<SourceNodeMetaDataType.SourceNode>;
};
/**
* Returns the meta data of a file
*
* since a meta data file is anonymized (no absolute path is stored)
* there is a total of three paths necessary to retrieve the correct meta data of a file
*
* this.relativeRootDir:
* describes the location of the execution (relative to the meta data file)
*
* projectReportFilePath:
* is the current location of the ProjectReport file
*
* relativeFilePath:
* is the location of a measured source file,
* relative to the execution path (this.relativeRootDir)
*
* All measurements are stored in this.lang_internal, this,intern and this,extern
* the keys are the corresponding relativeFilePaths
*
* the absolute path of the measured source file is:
* path.join(projectReportFilePath, this.relativeRootDir, relativeFilePath)
*
* therefore the relativeFilePath of the absolute one is:
* const relativeFilePath = path.relative(path.join(projectReportFilePath, this.relativeRootDir), absoluteFilePath)
*
* @param projectReportFilePath is the current location of the ProjectReport file
* @param absoluteFilePath is the absolute path of the measured source file
* @returns the measurements of the given source file
*/
getMetaDataFromFile(projectReportFilePath: UnifiedPath, absoluteFilePath: UnifiedPath): SourceFileMetaData | undefined;
/**
* @returns the total sensor values (sum) and the maximum (max) of all measurements in the report
*/
totalAndMaxMetaData(): AggregatedSourceNodeMetaData;
validate(): void;
toJSON(): IReport;
static fromJSONReport(json: string | IReport, moduleIndex: ModuleIndex): Report;
storeToFileReport(filePath: UnifiedPath, kind: 'pretty-json' | 'json' | 'bin', type: ReportType, config?: ProfilerConfig): void;
static merge(moduleIndex: ModuleIndex, ...args: (ProjectReport | ModuleReport)[]): Report;
toBuffer(type: ReportType): Buffer;
static consumeFromBufferReport(buffer: Buffer, moduleIndex: ModuleIndex): {
instance: Report;
type: ReportType;
remainingBuffer: Buffer;
};
}
import { ModuleReport } from './ModuleReport';
import { ProjectReport } from './ProjectReport';