Skip to content

Commit

Permalink
[Profiling] Scale diff functions summary
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Jun 28, 2023
1 parent faab91c commit 7deb07d
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions x-pack/plugins/profiling/public/components/topn_functions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,28 @@ interface Row {
}

function TotalSamplesStat({
totalSamples,
newSamples,
baselineTotalSamples,
baselineScaleFactor,
comparisonTotalSamples,
comparisonScaleFactor,
}: {
totalSamples: number;
newSamples: number | undefined;
baselineTotalSamples: number;
baselineScaleFactor?: number;
comparisonTotalSamples?: number;
comparisonScaleFactor?: number;
}) {
const value = totalSamples.toLocaleString();
const scaledBaselineTotalSamples = scaleValue({
value: baselineTotalSamples,
scaleFactor: baselineScaleFactor,
});

const value = scaledBaselineTotalSamples.toLocaleString();

const sampleHeader = i18n.translate('xpack.profiling.functionsView.totalSampleCountLabel', {
defaultMessage: ' Total sample estimate: ',
});

if (newSamples === undefined || newSamples === 0) {
if (comparisonTotalSamples === undefined || comparisonTotalSamples === 0) {
return (
<EuiStat
title={<EuiText style={{ fontWeight: 'bold' }}>{value}</EuiText>}
Expand All @@ -67,8 +76,13 @@ function TotalSamplesStat({
);
}

const diffSamples = totalSamples - newSamples;
const percentDelta = (diffSamples / (totalSamples - diffSamples)) * 100;
const scaledComparisonTotalSamples = scaleValue({
value: comparisonTotalSamples,
scaleFactor: comparisonScaleFactor,
});

const diffSamples = scaledBaselineTotalSamples - scaledComparisonTotalSamples;
const percentDelta = (diffSamples / (scaledBaselineTotalSamples - diffSamples)) * 100;

return (
<EuiStat
Expand Down Expand Up @@ -408,8 +422,10 @@ export function TopNFunctionsTable({
return (
<>
<TotalSamplesStat
totalSamples={totalCount}
newSamples={comparisonTopNFunctions?.TotalCount}
baselineTotalSamples={totalCount}
baselineScaleFactor={baselineScaleFactor}
comparisonTotalSamples={comparisonTopNFunctions?.TotalCount}
comparisonScaleFactor={comparisonScaleFactor}
/>
<EuiSpacer size="s" />
<EuiHorizontalRule margin="none" style={{ height: 2 }} />
Expand Down

0 comments on commit 7deb07d

Please sign in to comment.