mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[ObsUX][Profiling] Remove float numbers on samples (#211489)
Closes https://github.com/elastic/kibana/issues/181295 #### Summary There should be no decimal / fraction in the number of samples (those are integer values). #### What was done When the scale factor was a number with decimals, was changing the value of the samples to a float number Also, the background color for the `Normalized By` dropdown was fixed in dark mode Before <img width="1335" alt="image" src="https://github.com/user-attachments/assets/93b6c301-5b7f-41b6-857b-3551cf88b095" /> After <img width="1335" alt="image" src="https://github.com/user-attachments/assets/ebbe78ed-d8cb-4308-acf4-0d15221f986b" />
This commit is contained in:
parent
8f7f6a7a81
commit
5b96461ee7
4 changed files with 21 additions and 12 deletions
|
@ -18,7 +18,7 @@ import { isEmpty } from 'lodash';
|
|||
import React, { useMemo } from 'react';
|
||||
import { asCost } from '../../utils/formatters/as_cost';
|
||||
import { asWeight } from '../../utils/formatters/as_weight';
|
||||
import { calculateBaseComparisonDiff } from '../topn_functions/utils';
|
||||
import { calculateBaseComparisonDiff, scaleAndRoundValue } from '../topn_functions/utils';
|
||||
import { SummaryItem } from './summary_item';
|
||||
|
||||
interface FrameValue {
|
||||
|
@ -40,10 +40,6 @@ const ESTIMATED_VALUE_LABEL = i18n.translate('xpack.profiling.diffTopNFunctions.
|
|||
defaultMessage: 'Estimated value',
|
||||
}) as string;
|
||||
|
||||
function getScaleFactor(scaleFactor: number = 1) {
|
||||
return scaleFactor;
|
||||
}
|
||||
|
||||
export function FramesSummary({
|
||||
baseValue,
|
||||
comparisonValue,
|
||||
|
@ -52,11 +48,14 @@ export function FramesSummary({
|
|||
compressed = false,
|
||||
}: Props) {
|
||||
const baselineScaledTotalSamples = baseValue
|
||||
? baseValue.totalCount * getScaleFactor(baseValue.scaleFactor)
|
||||
? scaleAndRoundValue({ value: baseValue.totalCount, scaleFactor: baseValue.scaleFactor })
|
||||
: 0;
|
||||
|
||||
const comparisonScaledTotalSamples = comparisonValue
|
||||
? comparisonValue.totalCount * getScaleFactor(comparisonValue.scaleFactor)
|
||||
? scaleAndRoundValue({
|
||||
value: comparisonValue.totalCount,
|
||||
scaleFactor: comparisonValue.scaleFactor,
|
||||
})
|
||||
: 0;
|
||||
|
||||
const { co2EmissionDiff, costImpactDiff, totalSamplesDiff } = useMemo(() => {
|
||||
|
|
|
@ -113,7 +113,7 @@ export function NormalizationMenu(props: Props) {
|
|||
style={{
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
backgroundColor: theme.euiTheme.colors.ghost,
|
||||
backgroundColor: theme.euiTheme.colors.backgroundBasePlain,
|
||||
padding: '0 16px',
|
||||
}}
|
||||
>
|
||||
|
|
|
@ -9,7 +9,7 @@ import { EuiStat, EuiText } from '@elastic/eui';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import React from 'react';
|
||||
import { Label } from './label';
|
||||
import { scaleValue } from './utils';
|
||||
import { scaleAndRoundValue } from './utils';
|
||||
|
||||
interface Props {
|
||||
baselineTotalSamples: number;
|
||||
|
@ -24,7 +24,7 @@ export function TotalSamplesStat({
|
|||
comparisonTotalSamples,
|
||||
comparisonScaleFactor,
|
||||
}: Props) {
|
||||
const scaledBaselineTotalSamples = scaleValue({
|
||||
const scaledBaselineTotalSamples = scaleAndRoundValue({
|
||||
value: baselineTotalSamples,
|
||||
scaleFactor: baselineScaleFactor,
|
||||
});
|
||||
|
@ -44,7 +44,7 @@ export function TotalSamplesStat({
|
|||
);
|
||||
}
|
||||
|
||||
const scaledComparisonTotalSamples = scaleValue({
|
||||
const scaledComparisonTotalSamples = scaleAndRoundValue({
|
||||
value: comparisonTotalSamples,
|
||||
scaleFactor: comparisonScaleFactor,
|
||||
});
|
||||
|
|
|
@ -32,10 +32,20 @@ export function getColorLabel(percent: number) {
|
|||
return { color: 'text', label: undefined, icon: undefined };
|
||||
}
|
||||
|
||||
export function scaleValue({ value, scaleFactor = 1 }: { value: number; scaleFactor?: number }) {
|
||||
function scaleValue({ value, scaleFactor = 1 }: { value: number; scaleFactor?: number }) {
|
||||
return value * scaleFactor;
|
||||
}
|
||||
|
||||
export function scaleAndRoundValue({
|
||||
value,
|
||||
scaleFactor = 1,
|
||||
}: {
|
||||
value: number;
|
||||
scaleFactor?: number;
|
||||
}) {
|
||||
return Math.round(scaleValue({ value, scaleFactor }));
|
||||
}
|
||||
|
||||
export const getTotalCount = (topNFunctions?: TopNFunctions) => topNFunctions?.selfCPU ?? 0;
|
||||
|
||||
export interface IFunctionRow {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue