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

[Profiling] Scale diff functions summary #160708

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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