mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
62 lines
935 B
Beef
62 lines
935 B
Beef
using System;
|
|
using Beefy.utils;
|
|
|
|
namespace GlitchyEngine.Debug
|
|
{
|
|
public static class Profiler
|
|
{
|
|
#if !GE_PROFILE
|
|
[SkipCall]
|
|
#endif
|
|
public static void BeginProfiling(StringView serverName = "127.0.0.1", StringView sessionName = "GlitchyEngine")
|
|
{
|
|
BeefPerf.Init(serverName, sessionName);
|
|
}
|
|
|
|
#if !GE_PROFILE
|
|
[SkipCall]
|
|
#endif
|
|
public static void EndProfiling()
|
|
{
|
|
BeefPerf.Shutdown();
|
|
}
|
|
|
|
#if !GE_PROFILE
|
|
[SkipCall]
|
|
#endif
|
|
public static mixin ProfileFunction()
|
|
{
|
|
scope:mixin PerformanceTimer()
|
|
}
|
|
|
|
#if !GE_PROFILE
|
|
[SkipCall]
|
|
#endif
|
|
public static mixin ProfileScope(char8* scopeName)
|
|
{
|
|
scope:mixin PerformanceTimer(scopeName)
|
|
}
|
|
}
|
|
|
|
class PerformanceTimer
|
|
{
|
|
[Inline]
|
|
public this(char8* name = Compiler.CallerMemberName)
|
|
{
|
|
#if GE_PROFILE
|
|
[Inline]
|
|
BeefPerf.Enter(name);
|
|
#endif
|
|
}
|
|
|
|
[Inline]
|
|
public ~this()
|
|
{
|
|
#if GE_PROFILE
|
|
[Inline]
|
|
BeefPerf.Leave();
|
|
#endif
|
|
}
|
|
}
|
|
}
|