Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: parser performance #472

Merged
merged 9 commits into from
Jan 10, 2024
56 changes: 21 additions & 35 deletions log-viewer/modules/__tests__/ApexLogParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ import {
TimedNode,
lineTypeMap,
parse,
parseLineNumber,
parseObjectNamespace,
parseRows,
parseTimestamp,
parseVfNamespace,
} from '../parsers/ApexLogParser.js';

Expand Down Expand Up @@ -43,18 +41,6 @@ describe('parseVfNamespace tests', () => {
});
});

describe('parseTimestamp tests', () => {
it("Should parse the timestamp from it's section", () => {
expect(parseTimestamp('22:00:05.0 (59752074)')).toEqual(59752074);
});
});

describe('parseLineNumber tests', () => {
it("Should parse the line-number from it's section", () => {
expect(parseLineNumber('[37]')).toEqual(37);
});
});

describe('parseRows tests', () => {
it("Should parse the row-count from it's section", () => {
expect(parseRows('Rows:12')).toEqual(12);
Expand Down Expand Up @@ -93,20 +79,32 @@ describe('Pseudo EXIT events', () => {
expect(log1.duration).toEqual({ self: 0, total: 3 });

const approval1 = log1.children[0] as Method;
expect(approval1.duration).toEqual({ self: 1, total: 1 });
expect(approval1.type).toEqual('WF_APPROVAL_SUBMIT');
expect(approval1).toMatchObject({
type: 'WF_APPROVAL_SUBMIT',
timestamp: 1,
duration: { self: 1, total: 1 },
});

const processFound1 = log1.children[1] as Method;
expect(processFound1.duration).toEqual({ self: 1, total: 1 });
expect(processFound1.type).toEqual('WF_PROCESS_FOUND');
expect(processFound1).toMatchObject({
type: 'WF_PROCESS_FOUND',
timestamp: 2,
duration: { self: 1, total: 1 },
});

const approval2 = log1.children[2] as Method;
expect(approval2.duration).toEqual({ self: 1, total: 1 });
expect(approval2.type).toEqual('WF_APPROVAL_SUBMIT');
expect(approval2).toMatchObject({
type: 'WF_APPROVAL_SUBMIT',
timestamp: 3,
duration: { self: 1, total: 1 },
});

const processFound2 = log1.children[3] as Method;
expect(processFound2.duration).toEqual({ self: 0, total: 0 }); // no lines after the last WF_PROCESS_FOUND to use as an exit
expect(processFound2.type).toEqual('WF_PROCESS_FOUND');
expect(processFound2).toMatchObject({
type: 'WF_PROCESS_FOUND',
timestamp: 4,
duration: { self: 0, total: 0 }, // no lines after the last WF_PROCESS_FOUND to use as an exit
});
});

it('Pseudo EXIT With Entry after last event', () => {
Expand Down Expand Up @@ -693,21 +691,9 @@ describe('Recalculate durations tests', () => {
node.exitStamp = 3;

node.recalculateDurations();
expect(node.timestamp).toEqual(1);
expect(node.duration).toEqual({ self: 2, total: 2 });
});

it('Children are subtracted from net duration', () => {
const node = new Method(['14:32:07.563 (0)', 'DUMMY'], [], 'Method', ''),
child1 = new Method(['14:32:07.563 (10)', 'DUMMY'], [], 'Method', ''),
child2 = new Method(['14:32:07.563 (70)', 'DUMMY'], [], 'Method', '');
node.exitStamp = 100;
child1.duration.total = 50;
child2.duration.total = 25;
node.addChild(child1);
node.addChild(child2);
node.recalculateDurations();
expect(node.duration).toEqual({ self: 25, total: 100 });
});
});

describe('Line Type Tests', () => {
Expand Down
Loading