UE4 自定义Stat 命令

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/maxiaosheng521/article/details/97282445

下面的例子就是统计BeginPlay的执行次数

#include "TestActor.h"
DECLARE_STATS_GROUP(TEXT("Group Name"), STATGROUP_LODZERO, STATCAT_Advanced); //声明命令名称LODZERO
DECLARE_DWORD_ACCUMULATOR_STAT(TEXT("stat count"), STAT_COUNT, STATGROUP_LODZERO); //统计个数
DECLARE_CYCLE_STAT(TEXT("stat time"), STAT_TIME, STATGROUP_LODZERO); //统计时间


// Sets default values
ATestActor::ATestActor()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void ATestActor::BeginPlay()
{
	
	Super::BeginPlay();
	INC_DWORD_STAT(STAT_COUNT);
	
}

// Called every frame
void ATestActor::Tick(float DeltaTime)
{
	SCOPE_CYCLE_COUNTER(STAT_TIME);
	for (int i = 0; i < 100000; i++)
	{
		int a = 1 + i;
	}
	Super::Tick(DeltaTime);
	
}

在command中输入stat lodzero 结果

 

展开阅读全文

没有更多推荐了,返回首页