一日分の備忘録

ゲーム制作におけるいろいろな実装の備忘録。基本的にはゲームエンジン中心。その中でもUE4がメイン。プログラマーなのでプログラム的な記事が多くなるかも

処理時間計測の備忘録

BPのある部分のみ処理時間を計測したくなったのを気になったので作成。
この処理自体の処理時間はわかりません。

C++クラスを作成。
.h

UFUNCTION(BlueprintCallable, Category = "Clock")
static void StartClock();

UFUNCTION(BlueprintCallable, Category = "Clock")
static float EndClock();

.cpp

#include <windows.h>

static LARGE_INTEGER freq;

static LARGE_INTEGER start_time, end_time;

void UClock::StartClock()
{
	QueryPerformanceFrequency(&freq);
	QueryPerformanceCounter(&start_time);
}


float UClock::EndClock()
{
	QueryPerformanceCounter(&end_time);
		
	return 1000 * (float)(end_time.QuadPart - start_time.QuadPart) / freq.QuadPart;
}

適当に重い処理を書いて計測。
f:id:oneday-memorandum:20170816160207p:plain

こんな感じで使う
f:id:oneday-memorandum:20170816160212p:plain