Skip to content

Commit

Permalink
[Profiling] Fix TopN function total CPU value (#188848)
Browse files Browse the repository at this point in the history
closes #188511

<img width="2784" alt="Screenshot 2024-07-22 at 13 59 28"
src="https://github.com/user-attachments/assets/910ae596-ef22-4c18-b31f-7a9016e3b61d">
<img width="2756" alt="Screenshot 2024-07-22 at 14 55 50"
src="https://github.com/user-attachments/assets/66be5e9f-0d55-4b02-b97a-1425b6f0420c">
15
  • Loading branch information
cauemarcondes authored Jul 23, 2024
1 parent a9db600 commit 2ced941
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ describe('Functions page', () => {
const firstRowSelector = '[data-grid-row-index="0"] [data-test-subj="dataGridRowCell"]';
cy.get(firstRowSelector).eq(1).contains('1');
cy.get(firstRowSelector).eq(2).contains('vmlinux');
cy.get(firstRowSelector).eq(3).contains('0.16%');
cy.get(firstRowSelector).eq(4).contains('0.16%');
cy.get(firstRowSelector).eq(3).contains('5.46%');
cy.get(firstRowSelector).eq(4).contains('5.46%');
cy.get(firstRowSelector).eq(5).contains('3.97 lbs / 1.8 kg');
cy.get(firstRowSelector).eq(6).contains('$17.37');
cy.get(firstRowSelector).eq(7).contains('28');
Expand All @@ -56,8 +56,8 @@ describe('Functions page', () => {
{ parentKey: 'informationRows', key: 'executable', value: 'vmlinux' },
{ parentKey: 'informationRows', key: 'function', value: 'N/A' },
{ parentKey: 'informationRows', key: 'sourceFile', value: 'N/A' },
{ parentKey: 'impactEstimates', key: 'totalCPU', value: '0.16%' },
{ parentKey: 'impactEstimates', key: 'selfCPU', value: '0.16%' },
{ parentKey: 'impactEstimates', key: 'totalCPU', value: '5.46%' },
{ parentKey: 'impactEstimates', key: 'selfCPU', value: '5.46%' },
{ parentKey: 'impactEstimates', key: 'samples', value: '28' },
{ parentKey: 'impactEstimates', key: 'selfSamples', value: '28' },
{ parentKey: 'impactEstimates', key: 'coreSeconds', value: '1.4 seconds' },
Expand Down Expand Up @@ -118,16 +118,16 @@ describe('Functions page', () => {
columnIndex: 3,
highRank: 1,
lowRank: 389,
highValue: '0.16%',
highValue: '5.46%',
lowValue: '0.00%',
},
{
columnKey: 'totalCPU',
columnIndex: 4,
highRank: 693,
lowRank: 44,
highValue: '1.80%',
lowValue: '0.01%',
highValue: '60.43%',
lowValue: '0.19%',
},
{
columnKey: 'annualizedCo2',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Top N functions: Utils', () => {
expect(getTotalCount()).toEqual(0);
});
it('returns value from topNFunctions', () => {
expect(getTotalCount({ TotalCount: 10 } as TopNFunctions)).toEqual(10);
expect(getTotalCount({ selfCPU: 10 } as TopNFunctions)).toEqual(10);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function scaleValue({ value, scaleFactor = 1 }: { value: number; scaleFac
return value * scaleFactor;
}

export const getTotalCount = (topNFunctions?: TopNFunctions) => topNFunctions?.TotalCount ?? 0;
export const getTotalCount = (topNFunctions?: TopNFunctions) => topNFunctions?.selfCPU ?? 0;

export interface IFunctionRow {
id: string;
Expand Down Expand Up @@ -95,15 +95,15 @@ export function getFunctionsRows({
scaleFactor: baselineScaleFactor,
});

const totalCPUPerc = (topN.CountInclusive / topNFunctions.TotalCount) * 100;
const selfCPUPerc = (topN.CountExclusive / topNFunctions.TotalCount) * 100;
const totalCPUPerc = (topN.CountInclusive / topNFunctions.selfCPU) * 100;
const selfCPUPerc = (topN.CountExclusive / topNFunctions.selfCPU) * 100;

const impactEstimates =
totalSeconds > 0
? calculateImpactEstimates({
countExclusive: topN.CountExclusive,
countInclusive: topN.CountInclusive,
totalSamples: topNFunctions.TotalCount,
totalSamples: topNFunctions.selfCPU,
totalSeconds,
})
: undefined;
Expand All @@ -124,10 +124,9 @@ export function getFunctionsRows({
selfCPU: comparisonRow.CountExclusive,
totalCPU: comparisonRow.CountInclusive,
selfCPUPerc:
selfCPUPerc - (comparisonRow.CountExclusive / comparisonTopNFunctions.TotalCount) * 100,
selfCPUPerc - (comparisonRow.CountExclusive / comparisonTopNFunctions.selfCPU) * 100,
totalCPUPerc:
totalCPUPerc -
(comparisonRow.CountInclusive / comparisonTopNFunctions.TotalCount) * 100,
totalCPUPerc - (comparisonRow.CountInclusive / comparisonTopNFunctions.selfCPU) * 100,
selfAnnualCO2kgs: comparisonRow.selfAnnualCO2kgs,
selfAnnualCostUSD: comparisonRow.selfAnnualCostUSD,
totalAnnualCO2kgs: comparisonRow.totalAnnualCO2kgs,
Expand Down

0 comments on commit 2ced941

Please sign in to comment.