#pragma once
#include "CoreMinimal.h"

//Toggle to enable/disable timing code logs
#define ENABLE_EMOSHAPE_PRECISE_TIMER 1

/** 
*	C++ Utility Timer class. Multiple categories can be used simultaneously.
*
*	Usage: 
*	FEmoShapeMeasureTimer::Tick(TEXT("MyMeasurementCategory"));
*	//Your code
*	FEmoShapeMeasureTimer::Tock(TEXT("MyMeasurementCategory")); //This will log the time taken in miliseconds
*
*	optionally get the result and handle logging manually
*	double Elapsed = FEmoShapeMeasureTimer::Tock(TEXT("MyMeasurementCategory", false);
*/

class EMOSHAPESUBSYSTEM_API FESMeasureTimer
{
public:
	/**
	*	Start a timer for given category
	*/
	static void Tick(const FString& LogMsg = TEXT("TimeTaken"));

	/**
	*	Returns time taken in milliseconds (to micro precision). This function will also log the time taken
	*/
	static double Tock(const FString& LogMsg = TEXT("TimeTaken"), bool bShouldLogResult = true);

private:
	double Then;
};

/** 
*	Wrapper for FEmoShapeMeasureTimer calls. 
*
*	Usage:
*	{
*		//code you do not wish to measure
*
*		FEmoShapeScopeTimer Timer(TEXT("My Message"));
*
*		//your code
*	}
*	It will log duration when you exit the scope
*/
class EMOSHAPESUBSYSTEM_API FESScopeTimer
{
public:
	FESScopeTimer(const FString& InLogMsg);
	~FESScopeTimer();
private:
	FString LogMessage;
	
};
