From d0358f5d2d3b386230332d00fc7f99c295ed107a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cau=C3=AA=20Marcondes?=
<55978943+cauemarcondes@users.noreply.github.com>
Date: Wed, 28 Jun 2023 13:00:55 +0100
Subject: [PATCH] [Profiling] Scale diff functions summary (#160708)
This PR fixes a problem where the Total sample summary value wasn't
being scaled when a scale factor is selected.
---
.../components/topn_functions/index.tsx | 36 +++++++++++++------
1 file changed, 26 insertions(+), 10 deletions(-)
diff --git a/x-pack/plugins/profiling/public/components/topn_functions/index.tsx b/x-pack/plugins/profiling/public/components/topn_functions/index.tsx
index c43ecd2ac0cec..7320f11d24ec1 100644
--- a/x-pack/plugins/profiling/public/components/topn_functions/index.tsx
+++ b/x-pack/plugins/profiling/public/components/topn_functions/index.tsx
@@ -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 (
{value}}
@@ -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 (