277 lines
13 KiB
C++
277 lines
13 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "STimersViewTooltip.h"
|
|
|
|
#include "EditorStyleSet.h"
|
|
#include "SlateOptMacros.h"
|
|
#include "TraceServices/Model/AnalysisSession.h"
|
|
#include "Widgets/Layout/SGridPanel.h"
|
|
#include "Widgets/Layout/SSeparator.h"
|
|
#include "Widgets/SBoxPanel.h"
|
|
#include "Widgets/SToolTip.h"
|
|
#include "Widgets/Text/STextBlock.h"
|
|
|
|
// Insights
|
|
#include "Insights/Common/TimeUtils.h"
|
|
#include "Insights/Table/ViewModels/Table.h"
|
|
#include "Insights/Table/ViewModels/TableColumn.h"
|
|
#include "Insights/ViewModels/TimerNode.h"
|
|
#include "Insights/ViewModels/TimerNodeHelper.h"
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#define LOCTEXT_NAMESPACE "STimersView"
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
|
|
|
|
TSharedPtr<SToolTip> STimersViewTooltip::GetTableTooltip(const Insights::FTable& Table)
|
|
{
|
|
TSharedPtr<SToolTip> ColumnTooltip =
|
|
SNew(SToolTip)
|
|
[SNew(SVerticalBox)
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(Table.GetDisplayName())
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))]
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(Table.GetDescription())
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))]];
|
|
|
|
return ColumnTooltip;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
TSharedPtr<SToolTip> STimersViewTooltip::GetColumnTooltip(const Insights::FTableColumn& Column)
|
|
{
|
|
TSharedPtr<SToolTip> ColumnTooltip =
|
|
SNew(SToolTip)
|
|
[SNew(SVerticalBox)
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(Column.GetTitleName())
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))]
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(Column.GetDescription())
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))]];
|
|
|
|
return ColumnTooltip;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
TSharedPtr<SToolTip> STimersViewTooltip::GetRowTooltip(const TSharedPtr<FTimerNode> TimerNodePtr)
|
|
{
|
|
const Trace::FTimingProfilerAggregatedStats& Stats = TimerNodePtr->GetAggregatedStats();
|
|
|
|
const FText InstanceCountText = FText::AsNumber(Stats.InstanceCount);
|
|
|
|
const int32 NumDigits = 5;
|
|
|
|
TCHAR FormatString[32];
|
|
FCString::Snprintf(FormatString, sizeof(FormatString), TEXT("%%.%dfs (%%s)"), NumDigits);
|
|
|
|
const FText TotalInclusiveTimeText = FText::FromString(FString::Printf(FormatString, Stats.TotalInclusiveTime, *TimeUtils::FormatTimeAuto(Stats.TotalInclusiveTime, 2)));
|
|
const FText MinInclusiveTimeText = FText::FromString(TimeUtils::FormatTimeMs(Stats.MinInclusiveTime, NumDigits, true));
|
|
const FText MaxInclusiveTimeText = FText::FromString(TimeUtils::FormatTimeMs(Stats.MaxInclusiveTime, NumDigits, true));
|
|
const FText AvgInclusiveTimeText = FText::FromString(TimeUtils::FormatTimeMs(Stats.AverageInclusiveTime, NumDigits, true));
|
|
const FText MedInclusiveTimeText = FText::FromString(TimeUtils::FormatTimeMs(Stats.MedianInclusiveTime, NumDigits, true));
|
|
|
|
const FText TotalExclusiveTimeText = FText::FromString(FString::Printf(FormatString, Stats.TotalExclusiveTime, *TimeUtils::FormatTimeAuto(Stats.TotalExclusiveTime, 2)));
|
|
const FText MinExclusiveTimeText = FText::FromString(TimeUtils::FormatTimeMs(Stats.MinExclusiveTime, NumDigits, true));
|
|
const FText MaxExclusiveTimeText = FText::FromString(TimeUtils::FormatTimeMs(Stats.MaxExclusiveTime, NumDigits, true));
|
|
const FText AvgExclusiveTimeText = FText::FromString(TimeUtils::FormatTimeMs(Stats.AverageExclusiveTime, NumDigits, true));
|
|
const FText MedExclusiveTimeText = FText::FromString(TimeUtils::FormatTimeMs(Stats.MedianExclusiveTime, NumDigits, true));
|
|
|
|
TSharedPtr<SGridPanel> GridPanel;
|
|
TSharedPtr<SHorizontalBox> HBox;
|
|
|
|
TSharedPtr<SToolTip> TableCellTooltip =
|
|
SNew(SToolTip)
|
|
[SAssignNew(HBox, SHorizontalBox)
|
|
|
|
+ SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
[SNew(SVerticalBox)
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(SSeparator)
|
|
.Orientation(Orient_Horizontal)]
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(SGridPanel)
|
|
|
|
// Id: [Id]
|
|
+ SGridPanel::Slot(0, 0)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(LOCTEXT("TT_Id", "Id:"))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))] +
|
|
SGridPanel::Slot(1, 0)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(FText::AsNumber(TimerNodePtr->GetTimerId()))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))]
|
|
|
|
// Name: [Name]
|
|
+ SGridPanel::Slot(0, 1)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(LOCTEXT("TT_Name", "Name:"))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))] +
|
|
SGridPanel::Slot(1, 1)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.WrapTextAt(512.0f)
|
|
.WrappingPolicy(ETextWrappingPolicy::AllowPerCharacterWrapping)
|
|
.Text(FText::FromName(TimerNodePtr->GetName()))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))]
|
|
|
|
//// Group: [MetaGroupName]
|
|
//+ SGridPanel::Slot(0, 2)
|
|
//.Padding(2.0f)
|
|
//[
|
|
// SNew(STextBlock)
|
|
// .Text(LOCTEXT("TT_Group", "Group:"))
|
|
// .TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))
|
|
//]
|
|
//+ SGridPanel::Slot(1, 2)
|
|
//.Padding(2.0f)
|
|
//[
|
|
// SNew(STextBlock)
|
|
// .WrapTextAt(512.0f)
|
|
// .WrappingPolicy(ETextWrappingPolicy::AllowPerCharacterWrapping)
|
|
// .Text(FText::FromName(TimerNodePtr->GetMetaGroupName()))
|
|
// .TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))
|
|
//]
|
|
|
|
// Timer Type: [Type]
|
|
+ SGridPanel::Slot(0, 3)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(LOCTEXT("TT_Type", "Type:"))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))] +
|
|
SGridPanel::Slot(1, 3)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(TimerNodeTypeHelper::ToText(TimerNodePtr->GetType()))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))]]
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(SSeparator)
|
|
.Orientation(Orient_Horizontal)]
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(SGridPanel)
|
|
|
|
+ SGridPanel::Slot(0, 0)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(LOCTEXT("TT_NumInstances", "Num Instances:"))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))] +
|
|
SGridPanel::Slot(1, 0)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(InstanceCountText)
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))]]
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(SSeparator)
|
|
.Orientation(Orient_Horizontal)]
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SAssignNew(GridPanel, SGridPanel)
|
|
|
|
+ SGridPanel::Slot(1, 0)
|
|
.Padding(2.0f)
|
|
.HAlign(HAlign_Right)
|
|
[SNew(STextBlock)
|
|
.Text(LOCTEXT("TT_InclusiveTime", "Inclusive"))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))] +
|
|
SGridPanel::Slot(2, 0)
|
|
.Padding(FMargin(8.0f, 2.0f, 2.0f, 2.0f))
|
|
.HAlign(HAlign_Right)
|
|
[SNew(STextBlock)
|
|
.Text(LOCTEXT("TT_ExclusiveTime", "Exclusive"))
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))]
|
|
|
|
// Stats are added here.
|
|
]
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(2.0f)
|
|
[SNew(SSeparator)
|
|
.Orientation(Orient_Horizontal)]]];
|
|
|
|
int32 Row = 1;
|
|
AddStatsRow(GridPanel, Row, LOCTEXT("TT_TotalTime", "Total Time:"), TotalInclusiveTimeText, TotalExclusiveTimeText);
|
|
AddStatsRow(GridPanel, Row, LOCTEXT("TT_MaxTime", "Max Time:"), MaxInclusiveTimeText, MaxExclusiveTimeText);
|
|
AddStatsRow(GridPanel, Row, LOCTEXT("TT_AverageTime", "Average Time:"), AvgInclusiveTimeText, AvgExclusiveTimeText);
|
|
AddStatsRow(GridPanel, Row, LOCTEXT("TT_MedianTime", "Median Time:"), MedInclusiveTimeText, MedExclusiveTimeText);
|
|
AddStatsRow(GridPanel, Row, LOCTEXT("TT_MinTime", "Min Time:"), MinInclusiveTimeText, MinExclusiveTimeText);
|
|
|
|
return TableCellTooltip;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
void STimersViewTooltip::AddStatsRow(TSharedPtr<SGridPanel> Grid, int32& Row, const FText& Name, const FText& Value1, const FText& Value2)
|
|
{
|
|
Grid->AddSlot(0, Row)
|
|
.Padding(2.0f)
|
|
[SNew(STextBlock)
|
|
.Text(Name)
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.TooltipBold"))];
|
|
|
|
Grid->AddSlot(1, Row)
|
|
.Padding(2.0f)
|
|
.HAlign(HAlign_Right)
|
|
[SNew(STextBlock)
|
|
.Text(Value1)
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))];
|
|
|
|
Grid->AddSlot(2, Row)
|
|
.Padding(FMargin(8.0f, 2.0f, 2.0f, 2.0f))
|
|
.HAlign(HAlign_Right)
|
|
[SNew(STextBlock)
|
|
.Text(Value2)
|
|
.TextStyle(FEditorStyle::Get(), TEXT("Profiler.Tooltip"))];
|
|
|
|
Row++;
|
|
}
|
|
|
|
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#undef LOCTEXT_NAMESPACE
|