Skip to content

Commit 5529c8b

Browse files
Merge pull request #454 from lukecotter/feat-parser-duration-rollups
feat: parser duration rollups
2 parents 4d4b19b + 430785e commit 5529c8b

10 files changed

Lines changed: 132 additions & 90 deletions

File tree

lana/src/Context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import { type ExtensionContext, workspace } from 'vscode';
55

6-
import ShowAnalysisCodeLens from './codelenses/ShowAnalysisCodeLens.js';
6+
import { ShowAnalysisCodeLens } from './codelenses/ShowAnalysisCodeLens.js';
77
import { RetrieveLogFile } from './commands/RetrieveLogFile.js';
88
import { ShowLogAnalysis } from './commands/ShowLogAnalysis.js';
99
import { Display } from './display/Display.js';

lana/src/codelenses/ShowAnalysisCodeLens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ class ShowAnalysisCodeLens implements CodeLensProvider {
3939
}
4040
}
4141

42-
export default ShowAnalysisCodeLens;
42+
export { ShowAnalysisCodeLens };

log-viewer/modules/__tests__/ApexLogParser.test.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,22 @@ describe('Pseudo EXIT events', () => {
9090

9191
const log1 = parse(logData);
9292
expect(log1.children.length).toEqual(4);
93-
expect(log1.duration).toEqual(3);
93+
expect(log1.duration).toEqual({ self: 0, total: 3 });
9494

9595
const approval1 = log1.children[0] as Method;
96-
expect(approval1.duration).toEqual(1);
96+
expect(approval1.duration).toEqual({ self: 1, total: 1 });
9797
expect(approval1.type).toEqual('WF_APPROVAL_SUBMIT');
9898

9999
const processFound1 = log1.children[1] as Method;
100-
expect(processFound1.duration).toEqual(1);
100+
expect(processFound1.duration).toEqual({ self: 1, total: 1 });
101101
expect(processFound1.type).toEqual('WF_PROCESS_FOUND');
102102

103103
const approval2 = log1.children[2] as Method;
104-
expect(approval2.duration).toEqual(1);
104+
expect(approval2.duration).toEqual({ self: 1, total: 1 });
105105
expect(approval2.type).toEqual('WF_APPROVAL_SUBMIT');
106106

107107
const processFound2 = log1.children[3] as Method;
108-
expect(processFound2.duration).toEqual(0); // no lines after the last WF_PROCESS_FOUND to use as an exit
108+
expect(processFound2.duration).toEqual({ self: 0, total: 0 }); // no lines after the last WF_PROCESS_FOUND to use as an exit
109109
expect(processFound2.type).toEqual('WF_PROCESS_FOUND');
110110
});
111111

@@ -121,7 +121,7 @@ describe('Pseudo EXIT events', () => {
121121

122122
const log1 = parse(logData);
123123
expect(log1.children.length).toEqual(1);
124-
expect(log1.duration).toEqual(6);
124+
expect(log1.duration).toEqual({ self: 0, total: 6 });
125125

126126
const children = (log1.children[0] as Method).children;
127127
expect(children.length).toEqual(4);
@@ -153,7 +153,7 @@ describe('Pseudo EXIT events', () => {
153153

154154
const log1 = parse(logData);
155155
expect(log1.children.length).toEqual(1);
156-
expect(log1.duration).toEqual(4);
156+
expect(log1.duration).toEqual({ self: 0, total: 4 });
157157

158158
const children = (log1.children[0] as Method).children;
159159
expect(children.length).toEqual(3);
@@ -426,8 +426,8 @@ describe('parseLog tests', () => {
426426
const soqlLine = execEvent.children[0] as SOQLExecuteBeginLine;
427427
expect(soqlLine.type).toEqual('SOQL_EXECUTE_BEGIN');
428428
expect(soqlLine.aggregations).toEqual(2);
429-
expect(soqlLine.selfRowCount).toEqual(50);
430-
expect(soqlLine.totalRowCount).toEqual(50);
429+
expect(soqlLine.rowCount.self).toEqual(50);
430+
expect(soqlLine.rowCount.total).toEqual(50);
431431

432432
const soqlExplain = soqlLine.children[0] as SOQLExecuteExplainLine;
433433
expect(soqlExplain.type).toEqual('SOQL_EXECUTE_EXPLAIN');
@@ -474,7 +474,7 @@ describe('getRootMethod tests', () => {
474474
expect(interViewsBegin.children.length).toBe(1);
475475
const interViewBegin = interViewsBegin.children[0];
476476
expect(interViewBegin?.type).toBe('FLOW_START_INTERVIEW_BEGIN');
477-
expect(interViewBegin?.duration).toBe(6332706);
477+
expect(interViewBegin?.duration).toEqual({ self: 6332706, total: 6332706 });
478478
});
479479

480480
it('FlowStartInterviewsBeginLine should be a flow ', async () => {
@@ -509,7 +509,7 @@ describe('getRootMethod tests', () => {
509509
expect(interViewsBegin.children.length).toBe(1);
510510
const interViewBegin = interViewsBegin.children[0];
511511
expect(interViewBegin?.type).toBe('FLOW_START_INTERVIEW_BEGIN');
512-
expect(interViewBegin?.duration).toBe(6332706);
512+
expect(interViewBegin?.duration).toEqual({ self: 6332706, total: 6332706 });
513513
});
514514

515515
it('FlowStartInterviewsBeginLine should be a flow called from a process builder', async () => {
@@ -554,12 +554,12 @@ describe('getRootMethod tests', () => {
554554
expect(interViewsBegin.type).toBe('FLOW_START_INTERVIEWS_BEGIN');
555555
expect(interViewsBegin.text).toBe('FLOW_START_INTERVIEWS : Example Flow');
556556
expect(interViewsBegin.suffix).toBe(' (Flow)');
557-
expect(interViewsBegin.duration).toBe(3);
557+
expect(interViewsBegin.duration).toEqual({ self: 2, total: 3 });
558558

559559
expect(interViewsBegin.children.length).toBe(1);
560560
const interViewBegin = interViewsBegin.children[0];
561561
expect(interViewBegin?.type).toBe('FLOW_START_INTERVIEW_BEGIN');
562-
expect(interViewBegin?.duration).toBe(1);
562+
expect(interViewBegin?.duration).toEqual({ self: 1, total: 1 });
563563
});
564564

565565
it('Root exitStamp should match last line pair with a duration', async () => {
@@ -691,21 +691,20 @@ describe('Recalculate durations tests', () => {
691691
node.exitStamp = 3;
692692

693693
node.recalculateDurations();
694-
expect(node.duration).toBe(2);
695-
expect(node.selfTime).toBe(2);
694+
expect(node.duration).toEqual({ self: 2, total: 2 });
696695
});
696+
697697
it('Children are subtracted from net duration', () => {
698698
const node = new Method(['14:32:07.563 (0)', 'DUMMY'], [], 'Method', ''),
699699
child1 = new Method(['14:32:07.563 (10)', 'DUMMY'], [], 'Method', ''),
700700
child2 = new Method(['14:32:07.563 (70)', 'DUMMY'], [], 'Method', '');
701701
node.exitStamp = 100;
702-
child1.duration = 50;
703-
child2.duration = 25;
702+
child1.duration.total = 50;
703+
child2.duration.total = 25;
704704
node.addChild(child1);
705705
node.addChild(child2);
706706
node.recalculateDurations();
707-
expect(node.duration).toBe(100);
708-
expect(node.selfTime).toBe(25);
707+
expect(node.duration).toEqual({ self: 25, total: 100 });
709708
});
710709
});
711710

log-viewer/modules/components/AnalysisView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ function addNodeToMap(map: Map<string, Metric>, node: TimedNode, key?: string) {
255255
const children = node.children;
256256

257257
if (key) {
258-
const totalTime = node.duration;
259-
const selfTime = node.selfTime;
258+
const totalTime = node.duration.total;
259+
const selfTime = node.duration.self;
260260
let metric = map.get(key);
261261
if (!metric) {
262262
metric = new Metric(key, node);

log-viewer/modules/components/LogViewer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class LogViewer extends LitElement {
8181

8282
this.logSize = apexLog.size;
8383
this.timelineRoot = apexLog;
84-
this.logDuration = apexLog.duration;
84+
this.logDuration = apexLog.duration.total;
8585
document.dispatchEvent(
8686
new CustomEvent('logsettings', {
8787
detail: { logSettings: this.timelineRoot?.debugLevels },

log-viewer/modules/components/calltree-view/CalltreeView.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,13 @@ function toCallTree(nodes: LogLine[]): CalltreeRow[] | undefined {
488488
const data: CalltreeRow = {
489489
id: node.timestamp,
490490
text: node.text,
491-
duration: node.duration,
492-
selfTime: node.selfTime,
491+
duration: node.duration.total,
492+
selfTime: node.duration.self,
493493
_children: children,
494-
totalDmlCount: node.totalDmlCount,
495-
totalSoqlCount: node.totalSoqlCount,
494+
totalDmlCount: node.dmlCount.total,
495+
totalSoqlCount: node.soqlCount.total,
496496
totalThrownCount: node.totalThrownCount,
497-
rows: node.totalRowCount || 0,
497+
rows: node.rowCount.total,
498498
originalData: node,
499499
};
500500
results.push(data);
@@ -569,7 +569,7 @@ const showDetailsFilter = (data: CalltreeRow) => {
569569
return deepFilter(
570570
data,
571571
(rowData) => {
572-
return rowData.originalData.duration > 0 || rowData.originalData.discontinuity;
572+
return rowData.originalData.duration.total > 0 || rowData.originalData.discontinuity;
573573
},
574574
{
575575
filterCache: showDetailsFilterCache,

log-viewer/modules/components/database-view/DatabaseSection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class DatabaseSection extends LitElement {
3636
const totalCount = this.dbLines.length;
3737
let totalRows = 0;
3838
this.dbLines.forEach((value) => {
39-
totalRows += value.selfRowCount || 0;
39+
totalRows += value.rowCount.self || 0;
4040
});
4141

4242
return html`

log-viewer/modules/components/database-view/DatabaseView.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ function renderDMLTable(dmlTableContainer: HTMLElement, dmlLines: DMLBeginLine[]
190190
dmlText.push(dml.text);
191191
dmlData.push({
192192
dml: dml.text,
193-
rowCount: dml.selfRowCount,
194-
timeTaken: dml.duration,
193+
rowCount: dml.rowCount.self,
194+
timeTaken: dml.duration.total,
195195
timestamp: dml.timestamp,
196196
_children: [{ timestamp: dml.timestamp, isDetail: true }],
197197
});
@@ -388,8 +388,8 @@ function renderSOQLTable(soqlTableContainer: HTMLElement, soqlLines: SOQLExecute
388388
isSelective: explainLine?.relativeCost ? explainLine.relativeCost <= 1 : null,
389389
relativeCost: explainLine?.relativeCost,
390390
soql: soql.text,
391-
rowCount: soql.selfRowCount,
392-
timeTaken: soql.duration,
391+
rowCount: soql.rowCount.self,
392+
timeTaken: soql.duration.total,
393393
aggregations: soql.aggregations,
394394
timestamp: soql.timestamp,
395395
_children: [{ timestamp: soql.timestamp, isDetail: true }],

0 commit comments

Comments
 (0)