8#include "Engine/GameEngine.h"
9#include "Containers/UnrealString.h"
10#include "CoreMinimal.h"
87 void StopTimer(FString prefix =
"Code executed in ", FString suffix =
" milliseconds",
bool printToScreen =
false)
89 double endTime = FPlatformTime::Seconds();
90 float milliseconds = (endTime -
startTime) * 1000;
92 FString msString = FString::SanitizeFloat(milliseconds);
93 FString msg = prefix + msString + suffix;
94 UE_LOG(LogTemp, Warning, TEXT(
"%s"), *msg);
96 if (GEngine && printToScreen)
98 GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString::Printf(TEXT(
"%s"), *msg));
107 double endTime = FPlatformTime::Seconds();
108 float milliseconds = (endTime -
startTime) * 1000;
123 double PrintAverageTime(FString prefix =
"Average execution time ", FString suffix =
" milliseconds",
bool printToScreen =
false)
127 FString msString = FString::SanitizeFloat(currentAvg);
128 FString msg = prefix + msString + suffix;
131 UE_LOG(LogTemp, Warning, TEXT(
"%s"), *msg);
132 if (GEngine && printToScreen)
134 GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString::Printf(TEXT(
"%s"), *msg));
void StopTimer(FString prefix="Code executed in ", FString suffix=" milliseconds", bool printToScreen=false)
double PrintAverageTime(FString prefix="Average execution time ", FString suffix=" milliseconds", bool printToScreen=false)