Skip to content

Commit

Permalink
Merge pull request #130 from BalticAmadeus/develop
Browse files Browse the repository at this point in the history
1.1.1 release
  • Loading branch information
PauliusKu authored Dec 21, 2023
2 parents 664432d + 47f1af3 commit a5a5514
Show file tree
Hide file tree
Showing 15 changed files with 408 additions and 352 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.1.1 (2023-12-21)

### Changed

- Fixed various small bugs

## 1.1.0 (2023-11-10)

### Changed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pro-peek",
"displayName": "ProPeek",
"description": "Profiler app for OpenEdge ABL",
"version": "1.1.0",
"version": "1.1.1",
"publisher": "BalticAmadeus",
"engines": {
"vscode": "^1.78.0"
Expand Down
Binary file modified resources/images/propeek-open.webp
Binary file not shown.
2 changes: 1 addition & 1 deletion resources/markdown/release_instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
| ------ | ------------------------------------------------------------------------------------------------------------- | -------- |
| 1 | Create a new task in git for release plan (if it is not created already) | Everyone |
| 2 | Create release plan branch | Everyone |
| 3 | Write all completed tasks to release plan like this: - [] #15 | Everyone |
| 3 | Write all completed tasks to release plan like this: - [ ] #15 | Everyone |
| 4 | Update version in package.json (small update by 0.0.1 and big one by 0.1) | Everyone |
| 5 | Add main information to CHANGELOG. Changed for main bug fixes and Added for main new enhancement | Everyone |
| 6 | Add features to README | Everyone |
Expand Down
21 changes: 8 additions & 13 deletions src/common/PresentationData.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
export interface CalledModules {
moduleID: number,
calledModuleName?: string,
callerID: number,
calleeID: number,
callerModuleName: string,
calleeModuleName: string,
timesCalled: number,
totalTimesCalled: number,
pcntOfSession?: number
}

export interface CallingModules {
moduleID: number,
callingModuleName?: string,
timesCalling: number,
pcntOfSession?: number
calleeTotalTimesCalled: number,
callerPcntOfSession: number,
calleePcntOfSession: number
}

export interface LineSummary {
Expand All @@ -33,7 +29,7 @@ export interface ModuleDetails {
export interface CallTree {
nodeID: number,
parentID: number,
moduleID : number,
moduleID: number,
moduleName: string,
lineNum?: number,
numCalls?: number,
Expand All @@ -44,7 +40,6 @@ export interface CallTree {

export interface PresentationData {
moduleDetails: ModuleDetails[],
callingModules: CallingModules[],
calledModules: CalledModules[],
lineSummary: LineSummary[],
callTree: CallTree[]
Expand Down
22 changes: 22 additions & 0 deletions src/services/parser/ParserLogger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export class ParserLogger {
public static parserLogger: ParserLogger = new ParserLogger();
private static errors: string[] = [];

private constructor () {

}

public static logError(errorName: string, ...optionalParams: any[]) {
console.error(errorName, optionalParams);
ParserLogger.errors.push(errorName);
}

public static getErrors(): string[] {
return ParserLogger.errors;
}

public static resetErrors(): void {
ParserLogger.errors = [];
}

}
180 changes: 93 additions & 87 deletions src/services/parser/presentation/callTree.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CallTree, ModuleDetails } from "../../../common/PresentationData";
import { ParserLogger } from "../ParserLogger";
import { ProfilerRawData } from "../profilerRawData";
import { CallTreeData } from "../raw/callTreeData";
import { TracingData } from "../raw/tracingData";
Expand All @@ -9,37 +10,42 @@ import { TracingData } from "../raw/tracingData";
export function calculateCallTree(rawData: ProfilerRawData, moduleDetailList: ModuleDetails[], totalSessionTime: number): CallTree[] {

const callTree = [] as CallTree[];
const hasTracingData : boolean = false; //rawData.TracingData.length > 0;
const hasTracingData: boolean = false; //rawData.TracingData.length > 0;

let startNodeId : number = 0;
let sortedTracingData : TracingData[];
let startNodeId: number = 0;
let sortedTracingData: TracingData[] = [];

if (hasTracingData) {
startNodeId = rawData.CallTreeData.find(({ModuleID}) => ModuleID === rawData.TracingData[0].ModuleID)!.NodeID;
sortedTracingData = rawData.TracingData.sort((a, b) => a.StartTime! - b.StartTime!);
startNodeId = rawData.CallTreeData.find(({ ModuleID }) => ModuleID === rawData.TracingData[0].ModuleID)!.NodeID;
sortedTracingData = rawData.TracingData.sort((a, b) => a.StartTime! - b.StartTime!);
}

rawData.CallTreeData.forEach(node => {

if (node.NodeID >= startNodeId) {
let moduleDetails: ModuleDetails = moduleDetailList.find(({ moduleID }) => moduleID === node.ModuleID)!;

let callTreeNode : CallTree = {
nodeID : node.NodeID,
parentID : node.ParentID,
moduleID : node.ModuleID,
moduleName : moduleDetails.moduleName,
lineNum : node.LineNum,
numCalls : node.NumCalls,
cumulativeTime: node.CumulativeTime,
pcntOfSession : Number((node.CumulativeTime / totalSessionTime * 100).toFixed(4)),
// start time is currently not supported in flame graph
startTime : (hasTracingData? findStartTime(node, startNodeId, sortedTracingData) : undefined)
for (let node of rawData.CallTreeData) {
if (node.NodeID >= startNodeId) {
let moduleDetails: ModuleDetails = moduleDetailList.find(({ moduleID }) => moduleID === node.ModuleID)!;

if (!moduleDetails) {
ParserLogger.logError(`Module with ID ${node.ModuleID} not found`);

break;
}

let callTreeNode: CallTree = {
nodeID: node.NodeID,
parentID: node.ParentID,
moduleID: node.ModuleID,
moduleName: moduleDetails.moduleName,
lineNum: node.LineNum,
numCalls: node.NumCalls,
cumulativeTime: node.CumulativeTime,
pcntOfSession: Number((node.CumulativeTime / totalSessionTime * 100).toFixed(4)),
// start time is currently not supported in flame graph
startTime: (hasTracingData ? findStartTime(node, startNodeId, sortedTracingData) : undefined)
}

callTree.push(callTreeNode);
}

callTree.push(callTreeNode);
}
});
}

if (callTree[0].moduleID === 0) callTree.splice(0, 1);

Expand All @@ -49,21 +55,21 @@ export function calculateCallTree(rawData: ProfilerRawData, moduleDetailList: Mo
/**
* Finds start time of the node in Tracing Data section
*/
export function findStartTime(node : CallTreeData, startNodeId : number, sortedTracingData: TracingData[]): number {
export function findStartTime(node: CallTreeData, startNodeId: number, sortedTracingData: TracingData[]): number {

let tracingLineIndex : number;
let tracingLineIndex: number;

if (node.NodeID === startNodeId) {
tracingLineIndex = 0;
} else {
tracingLineIndex = sortedTracingData.findIndex(({ModuleID,LineNo}) => node.ModuleID === ModuleID && LineNo === 0)!;
}
if (node.NodeID === startNodeId) {
tracingLineIndex = 0;
} else {
tracingLineIndex = sortedTracingData.findIndex(({ ModuleID, LineNo }) => node.ModuleID === ModuleID && LineNo === 0)!;
}

const startTime : number = sortedTracingData[tracingLineIndex].StartTime;
const startTime: number = sortedTracingData[tracingLineIndex].StartTime;

sortedTracingData = sortedTracingData.splice(tracingLineIndex, 1);
sortedTracingData = sortedTracingData.splice(tracingLineIndex, 1);

return startTime;
return startTime;
}

/**
Expand All @@ -72,88 +78,88 @@ export function findStartTime(node : CallTreeData, startNodeId : number, sortedT
*/
export function calculateCallTreeByTracingData(rawData: ProfilerRawData, moduleDetailList: ModuleDetails[]): CallTree[] {

let callTree = [] as CallTree[];
let tracingData = rawData.TracingData;
let callTree = [] as CallTree[];
let tracingData = rawData.TracingData;

//tracing data section is optional, so no call tree in case it's empty
if (tracingData.length === 0) return callTree;
//tracing data section is optional, so no call tree in case it's empty
if (tracingData.length === 0) return callTree;

callTree = startTree(tracingData, moduleDetailList);
callTree = startTree(tracingData, moduleDetailList);

const totalSessionTime = callTree[0].cumulativeTime;
const totalSessionTime = callTree[0].cumulativeTime;

tracingData = tracingData.slice().reverse();
tracingData = tracingData.slice().reverse();

for(let index = 0; index < tracingData.length; index++){
//every node always starts with line 0
if (tracingData[index].LineNo === 0 && tracingData[index + 1].LineNo !== 0) {
pushNode(callTree, tracingData, index, moduleDetailList, totalSessionTime);
for (let index = 0; index < tracingData.length; index++) {
//every node always starts with line 0
if (tracingData[index].LineNo === 0 && tracingData[index + 1].LineNo !== 0) {
pushNode(callTree, tracingData, index, moduleDetailList, totalSessionTime);
}
}
}

callTree.sort((a, b) => a.startTime! - b.startTime!);
callTree.sort((a, b) => a.startTime! - b.startTime!);

return callTree;
return callTree;
}

/**
* Creates Call Tree and pushes first node of the tree based on Tracing data
*/
export function startTree(tracingData : TracingData[], moduleDetailList: ModuleDetails[]) : CallTree[] {
export function startTree(tracingData: TracingData[], moduleDetailList: ModuleDetails[]): CallTree[] {

let callTree = [] as CallTree[];
let callTree = [] as CallTree[];

const moduleDetails : ModuleDetails = moduleDetailList.find(({ moduleID }) => moduleID === tracingData[0].ModuleID)!;
const moduleDetails: ModuleDetails = moduleDetailList.find(({ moduleID }) => moduleID === tracingData[0].ModuleID)!;

const node : CallTree = {
nodeID: 1,
parentID: 0,
moduleID: moduleDetails.moduleID,
moduleName: moduleDetails.moduleName,
cumulativeTime: Number((tracingData[tracingData.length - 1].StartTime - tracingData[0].StartTime).toFixed(6)),
startTime: tracingData[0].StartTime,
pcntOfSession: 100
}
const node: CallTree = {
nodeID: 1,
parentID: 0,
moduleID: moduleDetails.moduleID,
moduleName: moduleDetails.moduleName,
cumulativeTime: Number((tracingData[tracingData.length - 1].StartTime - tracingData[0].StartTime).toFixed(6)),
startTime: tracingData[0].StartTime,
pcntOfSession: 100
}

callTree.push(node);
callTree.push(node);

return callTree;
return callTree;
}

/**
* Pushes a new node into the call tree
*/
export function pushNode(callTree : CallTree[], tracingData : TracingData[], index : number, moduleDetailList: ModuleDetails[], totalSessionTime : number) : CallTree[] {
export function pushNode(callTree: CallTree[], tracingData: TracingData[], index: number, moduleDetailList: ModuleDetails[], totalSessionTime: number): CallTree[] {

const moduleDetails : ModuleDetails = moduleDetailList.find(({ moduleID }) => moduleID === tracingData[index].ModuleID)!;
const currStartTime : number = tracingData[index].StartTime;
const parentModuleId = tracingData[index - 1].ModuleID;
const parent = callTree.sort((a, b) => b.startTime! - a.startTime!).find(({moduleID, startTime}) => moduleID === parentModuleId && startTime! <= currStartTime);
const moduleDetails: ModuleDetails = moduleDetailList.find(({ moduleID }) => moduleID === tracingData[index].ModuleID)!;
const currStartTime: number = tracingData[index].StartTime;
const parentModuleId = tracingData[index - 1].ModuleID;
const parent = callTree.sort((a, b) => b.startTime! - a.startTime!).find(({ moduleID, startTime }) => moduleID === parentModuleId && startTime! <= currStartTime);

if (!parent) return callTree;
if (!parent) return callTree;

let cumulativeTime : number = tracingData[index].ActualTime;
let cumulativeTime: number = tracingData[index].ActualTime;

// adjusting cumulative time as it initially doesn't include time of child nodes
for(let childIndex = index + 1; childIndex < tracingData.length; childIndex++){
const cumulativeTimeFromChild = tracingData[childIndex].StartTime + tracingData[childIndex].ActualTime - currStartTime;
// adjusting cumulative time as it initially doesn't include time of child nodes
for (let childIndex = index + 1; childIndex < tracingData.length; childIndex++) {
const cumulativeTimeFromChild = tracingData[childIndex].StartTime + tracingData[childIndex].ActualTime - currStartTime;

if(cumulativeTimeFromChild > cumulativeTime) {
cumulativeTime = Number(cumulativeTimeFromChild.toFixed(6));
if (cumulativeTimeFromChild > cumulativeTime) {
cumulativeTime = Number(cumulativeTimeFromChild.toFixed(6));
}
}
}

const node : CallTree = {
nodeID: callTree.length + 1,
parentID: parent!.nodeID,
moduleID: moduleDetails.moduleID,
moduleName: moduleDetails.moduleName,
cumulativeTime: cumulativeTime,
startTime: currStartTime,
pcntOfSession: Number((cumulativeTime / totalSessionTime * 100).toFixed(6))
}
const node: CallTree = {
nodeID: callTree.length + 1,
parentID: parent!.nodeID,
moduleID: moduleDetails.moduleID,
moduleName: moduleDetails.moduleName,
cumulativeTime: cumulativeTime,
startTime: currStartTime,
pcntOfSession: Number((cumulativeTime / totalSessionTime * 100).toFixed(6))
}

callTree.push(node);
callTree.push(node);

return callTree;
return callTree;
}
Loading

0 comments on commit a5a5514

Please sign in to comment.