UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ChaosPerfTest.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3#include "Misc/OutputDevice.h"
5
6#ifndef CHAOS_PERF_TEST_ENABLED
7#define CHAOS_PERF_TEST_ENABLED 1
8#endif
9
10#if CHAOS_PERF_TEST_ENABLED
12{
13 S,
14 Ms,
15 Us,
16 Num
17};
18
20{
21public:
23 : Label(InLabel)
24 , Device(GLog)
25 , Accumulator(0.0)
27 {
28 Timer.Start();
29 }
30
32 {
33 static const float Multipliers[static_cast<int>(EChaosPerfUnits::Num)] = { 1.f, 1000.f, 1000000.f };
34 static const TCHAR* Units[static_cast<int>(EChaosPerfUnits::Num)] = { TEXT("s"), TEXT("ms"), TEXT("us") };
35 Timer.Stop();
36 if (GlobalLabel)
37 {
38 //Device->Logf(TEXT("%s - %s: %4.fus"), GlobalLabel, Label, Accumulator * 1000000.f);
39 Device->Logf(TEXT("%s - %s: %f%s"), GlobalLabel, Label, Accumulator * Multipliers[static_cast<int>(GlobalUnits)], Units[static_cast<int>(GlobalUnits)]);
40 }
41 }
42
44
46
47 const TCHAR* Label;
51};
52
62
63#define CHAOS_PERF_TEST(x, units) FScopedChaosPerfTest Scope_##x(TEXT(#x), units);
64#define CHAOS_SCOPED_TIMER(x) FChaosScopedDurationTimeLogger Timer_##x(TEXT(#x));
65#else
66#define CHAOS_PERF_TEST(x, units)
67#define CHAOS_SCOPED_TIMER(x)
68#endif
EChaosPerfUnits
Definition ChaosPerfTest.h:12
#define GLog
Definition CoreGlobals.h:95
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition ChaosPerfTest.h:20
const TCHAR * Label
Definition ChaosPerfTest.h:47
FChaosScopedDurationTimeLogger(const TCHAR *InLabel)
Definition ChaosPerfTest.h:22
static CHAOS_API EChaosPerfUnits GlobalUnits
Definition ChaosPerfTest.h:45
static CHAOS_API const TCHAR * GlobalLabel
Definition ChaosPerfTest.h:43
double Accumulator
Definition ChaosPerfTest.h:49
~FChaosScopedDurationTimeLogger()
Definition ChaosPerfTest.h:31
FDurationTimer Timer
Definition ChaosPerfTest.h:50
FOutputDevice * Device
Definition ChaosPerfTest.h:48
Definition ScopedTimers.h:32
double Stop()
Definition ScopedTimers.h:45
double Start()
Definition ScopedTimers.h:39
Definition OutputDevice.h:133
void Logf(const FmtType &Fmt)
Definition OutputDevice.h:234
Definition ChaosPerfTest.h:54
FScopedChaosPerfTest(const TCHAR *InLabel, EChaosPerfUnits Units)
Definition ChaosPerfTest.h:55
~FScopedChaosPerfTest()
Definition ChaosPerfTest.h:60