Skip to content

Commit

Permalink
[Profiling] renaming CPU incl and CPU excl (#154560)
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes authored Apr 10, 2023
1 parent 1f8dc16 commit 5c759a1
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { calculateImpactEstimates } from '../../utils/calculate_impact_estimates
import { asCost } from '../../utils/formatters/as_cost';
import { asPercentage } from '../../utils/formatters/as_percentage';
import { asWeight } from '../../utils/formatters/as_weight';
import { CPULabelWithHint } from '../shared/cpu_label_with_hint';
import { TooltipRow } from './tooltip_row';

interface Props {
Expand Down Expand Up @@ -86,19 +87,29 @@ export function FlameGraphTooltip({
{isRoot === false && (
<>
<TooltipRow
label={i18n.translate('xpack.profiling.flameGraphTooltip.inclusiveCpuLabel', {
defaultMessage: `CPU incl. subfunctions`,
})}
label={
<CPULabelWithHint
type="total"
labelSize="xs"
iconSize="s"
labelStyle={{ fontWeight: 'bold' }}
/>
}
value={impactEstimates.percentage}
comparison={comparisonImpactEstimates?.percentage}
formatValue={asPercentage}
showDifference
formatDifferenceAsPercentage
/>
<TooltipRow
label={i18n.translate('xpack.profiling.flameGraphTooltip.exclusiveCpuLabel', {
defaultMessage: `CPU`,
})}
label={
<CPULabelWithHint
type="self"
labelSize="xs"
iconSize="s"
labelStyle={{ fontWeight: 'bold' }}
/>
}
value={impactEstimates.percentageNoChildren}
comparison={comparisonImpactEstimates?.percentageNoChildren}
showDifference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function TooltipRow({
formatValue,
}: {
value: number;
label: string;
label: string | React.ReactElement;
comparison?: number;
formatDifferenceAsPercentage: boolean;
showDifference: boolean;
Expand Down Expand Up @@ -58,7 +58,7 @@ export function TooltipRow({
<EuiFlexGroup direction="row" gutterSize="xs">
<EuiFlexItem grow={false}>
<EuiText size="xs">
<strong>{label}:</strong>
<strong style={{ display: 'flex' }}>{label}:</strong>
</EuiText>
</EuiFlexItem>
<EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
*/

import { i18n } from '@kbn/i18n';
import React from 'react';
import { calculateImpactEstimates } from '../../utils/calculate_impact_estimates';
import { asCost } from '../../utils/formatters/as_cost';
import { asDuration } from '../../utils/formatters/as_duration';
import { asNumber } from '../../utils/formatters/as_number';
import { asPercentage } from '../../utils/formatters/as_percentage';
import { asWeight } from '../../utils/formatters/as_weight';
import { CPULabelWithHint } from '../shared/cpu_label_with_hint';

export function getImpactRows({
countInclusive,
Expand Down Expand Up @@ -48,17 +50,11 @@ export function getImpactRows({

const impactRows = [
{
label: i18n.translate(
'xpack.profiling.flameGraphInformationWindow.percentageCpuTimeInclusiveLabel',
{ defaultMessage: '% of CPU time' }
),
label: <CPULabelWithHint type="total" labelSize="s" iconSize="s" />,
value: asPercentage(percentage),
},
{
label: i18n.translate(
'xpack.profiling.flameGraphInformationWindow.percentageCpuTimeExclusiveLabel',
{ defaultMessage: '% of CPU time (excl. children)' }
),
label: <CPULabelWithHint type="self" labelSize="s" iconSize="s" />,
value: asPercentage(percentageNoChildren),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule } from '@elastic/eui';
import React from 'react';

interface Props {
rows: Array<{ label: string; value: React.ReactNode }>;
rows: Array<{ label: string | React.ReactNode; value: React.ReactNode }>;
}

export function KeyValueList({ rows }: Props) {
Expand All @@ -19,7 +19,9 @@ export function KeyValueList({ rows }: Props) {
<>
<EuiFlexItem>
<EuiFlexGroup direction="row">
<EuiFlexItem grow>{row.label}:</EuiFlexItem>
<EuiFlexItem grow style={{ display: 'flex', flexDirection: 'row' }}>
{row.label}:
</EuiFlexItem>
<EuiFlexItem grow={false} style={{ alignSelf: 'flex-end', overflowWrap: 'anywhere' }}>
{row.value}
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import React from 'react';
import {
EuiFlexGroup,
EuiFlexItem,
EuiIcon,
EuiIconProps,
EuiText,
EuiTextProps,
EuiToolTip,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';

type CPUType = 'self' | 'total';

interface Props {
type: CPUType;
labelSize?: EuiTextProps['size'];
labelStyle?: EuiTextProps['style'];
iconSize?: EuiIconProps['size'];
}

const CPULabelHintMap: Record<CPUType, { label: string; hint: string }> = {
self: {
label: i18n.translate('xpack.profiling.cpu.self.label', {
defaultMessage: 'Self CPU',
}),
hint: i18n.translate('xpack.profiling.cpu.self.hint', {
defaultMessage:
'Indicates how much CPU time was spent by the code in the function body, excluding the work done by functions that were called by it',
}),
},
total: {
label: i18n.translate('xpack.profiling.cpu.total.label', {
defaultMessage: 'Total CPU',
}),
hint: i18n.translate('xpack.profiling.cpu.total.hint', {
defaultMessage:
'Indicates how much CPU time was spent by the function and any functions called by it',
}),
},
};

export function CPULabelWithHint({ iconSize, labelSize, labelStyle, type }: Props) {
const { label, hint } = CPULabelHintMap[type];

return (
<EuiFlexGroup gutterSize="xs" style={{ flexGrow: 0 }}>
<EuiFlexItem grow={false}>
<EuiText size={labelSize} style={labelStyle}>
{label}
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiToolTip content={hint}>
<EuiIcon type="questionInCircle" size={iconSize} />
</EuiToolTip>
</EuiFlexItem>
</EuiFlexGroup>
);
}
37 changes: 13 additions & 24 deletions x-pack/plugins/profiling/public/components/topn_functions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { calculateImpactEstimates } from '../../utils/calculate_impact_estimates
import { asCost } from '../../utils/formatters/as_cost';
import { asWeight } from '../../utils/formatters/as_weight';
import { FrameInformationTooltip } from '../frame_information_window/frame_information_tooltip';
import { CPULabelWithHint } from '../shared/cpu_label_with_hint';
import { StackFrameSummary } from '../stack_frame_summary';
import { GetLabel } from './get_label';

Expand Down Expand Up @@ -250,18 +251,12 @@ export function TopNFunctionsTable({
{
field: TopNFunctionSortField.ExclusiveCPU,
name: (
<EuiFlexGroup direction="column" gutterSize="xs">
<EuiFlexItem>
{i18n.translate('xpack.profiling.functionsView.cpuColumnLabel1Exclusive', {
defaultMessage: 'CPU excl.',
})}
</EuiFlexItem>
<EuiFlexItem>
{i18n.translate('xpack.profiling.functionsView.cpuColumnLabel2Exclusive', {
defaultMessage: 'subfunctions',
})}
</EuiFlexItem>
</EuiFlexGroup>
<CPULabelWithHint
type="self"
labelSize="xs"
labelStyle={{ fontWeight: 600 }}
iconSize="s"
/>
),
render: (_, { exclusiveCPU, diff }) => {
return <CPUStat cpu={exclusiveCPU} diffCPU={diff?.exclusiveCPU} />;
Expand All @@ -271,18 +266,12 @@ export function TopNFunctionsTable({
{
field: TopNFunctionSortField.InclusiveCPU,
name: (
<EuiFlexGroup direction="column" gutterSize="xs">
<EuiFlexItem>
{i18n.translate('xpack.profiling.functionsView.cpuColumnLabel1Inclusive', {
defaultMessage: 'CPU incl.',
})}
</EuiFlexItem>
<EuiFlexItem>
{i18n.translate('xpack.profiling.functionsView.cpuColumnLabel2Inclusive', {
defaultMessage: 'subfunctions',
})}
</EuiFlexItem>
</EuiFlexGroup>
<CPULabelWithHint
type="total"
labelSize="xs"
labelStyle={{ fontWeight: 600 }}
iconSize="s"
/>
),
render: (_, { inclusiveCPU, diff }) => {
return <CPUStat cpu={inclusiveCPU} diffCPU={diff?.inclusiveCPU} />;
Expand Down
8 changes: 0 additions & 8 deletions x-pack/plugins/translations/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -26359,8 +26359,6 @@
"xpack.profiling.flameGraphInformationWindow.executableLabel": "Exécutable",
"xpack.profiling.flameGraphInformationWindow.frameTypeLabel": "Type de cadre",
"xpack.profiling.flameGraphInformationWindow.functionLabel": "Fonction",
"xpack.profiling.flameGraphInformationWindow.percentageCpuTimeExclusiveLabel": "% de temps processeur (enfants excl.)",
"xpack.profiling.flameGraphInformationWindow.percentageCpuTimeInclusiveLabel": "% de temps processeur",
"xpack.profiling.flameGraphInformationWindow.samplesExclusiveLabel": "Échantillons (enfants excl.)",
"xpack.profiling.flameGraphInformationWindow.samplesInclusiveLabel": "Échantillons",
"xpack.profiling.flameGraphInformationWindow.sourceFileLabel": "Fichier source",
Expand All @@ -26378,13 +26376,7 @@
"xpack.profiling.flameGraphsView.differentialFlameGraphComparisonModeTitle": "Format",
"xpack.profiling.flameGraphsView.differentialFlameGraphTabLabel": "Flame-graph différentiel",
"xpack.profiling.flameGraphsView.flameGraphTabLabel": "Flame-graph",
"xpack.profiling.flameGraphTooltip.exclusiveCpuLabel": "CPU",
"xpack.profiling.flameGraphTooltip.inclusiveCpuLabel": "CPU incl. sous-fonctions",
"xpack.profiling.flameGraphTooltip.samplesLabel": "Échantillons",
"xpack.profiling.functionsView.cpuColumnLabel1Exclusive": "CPU excl.",
"xpack.profiling.functionsView.cpuColumnLabel1Inclusive": "CPU incl.",
"xpack.profiling.functionsView.cpuColumnLabel2Exclusive": "sous-fonctions",
"xpack.profiling.functionsView.cpuColumnLabel2Inclusive": "sous-fonctions",
"xpack.profiling.functionsView.diffColumnLabel": "Diff",
"xpack.profiling.functionsView.differentialFunctionsTabLabel": "Fonctions TopN différentielles",
"xpack.profiling.functionsView.functionColumnLabel": "Fonction",
Expand Down
8 changes: 0 additions & 8 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -26340,8 +26340,6 @@
"xpack.profiling.flameGraphInformationWindow.executableLabel": "実行ファイル",
"xpack.profiling.flameGraphInformationWindow.frameTypeLabel": "フレームタイプ",
"xpack.profiling.flameGraphInformationWindow.functionLabel": "関数",
"xpack.profiling.flameGraphInformationWindow.percentageCpuTimeExclusiveLabel": "CPU時間の割合(子を除く)",
"xpack.profiling.flameGraphInformationWindow.percentageCpuTimeInclusiveLabel": "CPU時間の割合",
"xpack.profiling.flameGraphInformationWindow.samplesExclusiveLabel": "サンプル(子を除く)",
"xpack.profiling.flameGraphInformationWindow.samplesInclusiveLabel": "サンプル",
"xpack.profiling.flameGraphInformationWindow.sourceFileLabel": "ソースファイル",
Expand All @@ -26359,13 +26357,7 @@
"xpack.profiling.flameGraphsView.differentialFlameGraphComparisonModeTitle": "フォーマット",
"xpack.profiling.flameGraphsView.differentialFlameGraphTabLabel": "差分flamegraph",
"xpack.profiling.flameGraphsView.flameGraphTabLabel": "Flamegraph",
"xpack.profiling.flameGraphTooltip.exclusiveCpuLabel": "CPU",
"xpack.profiling.flameGraphTooltip.inclusiveCpuLabel": "CPU(サブ関数を含む)",
"xpack.profiling.flameGraphTooltip.samplesLabel": "サンプル",
"xpack.profiling.functionsView.cpuColumnLabel1Exclusive": "CPU(",
"xpack.profiling.functionsView.cpuColumnLabel1Inclusive": "CPU(",
"xpack.profiling.functionsView.cpuColumnLabel2Exclusive": "サブ関数を含む)",
"xpack.profiling.functionsView.cpuColumnLabel2Inclusive": "サブ関数を含む)",
"xpack.profiling.functionsView.diffColumnLabel": "差分",
"xpack.profiling.functionsView.differentialFunctionsTabLabel": "差分上位N関数",
"xpack.profiling.functionsView.functionColumnLabel": "関数",
Expand Down
8 changes: 0 additions & 8 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -26356,8 +26356,6 @@
"xpack.profiling.flameGraphInformationWindow.executableLabel": "可执行",
"xpack.profiling.flameGraphInformationWindow.frameTypeLabel": "帧类型",
"xpack.profiling.flameGraphInformationWindow.functionLabel": "函数",
"xpack.profiling.flameGraphInformationWindow.percentageCpuTimeExclusiveLabel": "CPU 时间百分比(不包括子项)",
"xpack.profiling.flameGraphInformationWindow.percentageCpuTimeInclusiveLabel": "CPU 时间百分比",
"xpack.profiling.flameGraphInformationWindow.samplesExclusiveLabel": "样例(不包括子项)",
"xpack.profiling.flameGraphInformationWindow.samplesInclusiveLabel": "样例",
"xpack.profiling.flameGraphInformationWindow.sourceFileLabel": "源文件",
Expand All @@ -26375,13 +26373,7 @@
"xpack.profiling.flameGraphsView.differentialFlameGraphComparisonModeTitle": "格式",
"xpack.profiling.flameGraphsView.differentialFlameGraphTabLabel": "差异火焰图",
"xpack.profiling.flameGraphsView.flameGraphTabLabel": "火焰图",
"xpack.profiling.flameGraphTooltip.exclusiveCpuLabel": "CPU",
"xpack.profiling.flameGraphTooltip.inclusiveCpuLabel": "CPU 非独占时间(子函数)",
"xpack.profiling.flameGraphTooltip.samplesLabel": "样例",
"xpack.profiling.functionsView.cpuColumnLabel1Exclusive": "CPU 独占时间",
"xpack.profiling.functionsView.cpuColumnLabel1Inclusive": "CPU 非独占时间",
"xpack.profiling.functionsView.cpuColumnLabel2Exclusive": "子函数",
"xpack.profiling.functionsView.cpuColumnLabel2Inclusive": "子函数",
"xpack.profiling.functionsView.diffColumnLabel": "差异",
"xpack.profiling.functionsView.differentialFunctionsTabLabel": "差异 TopN 函数",
"xpack.profiling.functionsView.functionColumnLabel": "函数",
Expand Down

0 comments on commit 5c759a1

Please sign in to comment.