forked from AtomicGameEngine/AtomicGameEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfiler.cs
More file actions
49 lines (44 loc) · 1.98 KB
/
Profiler.cs
File metadata and controls
49 lines (44 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace AtomicEngine
{
public partial class Profiler : AObject
{
public static void Block(string name, Action block, uint color = 0xffffecb3,
ProfilerBlockStatus status = ProfilerBlockStatus.ON,
[CallerFilePath] string file = "",
[CallerLineNumber] int line = 0)
{
#if ATOMIC_PROFILING
var profiler = AtomicNET.Context.GetProfiler();
if (profiler != null)
csi_Atomic_Profiler_BeginBlock(profiler, name, file, line, color, (byte)status);
#endif
block();
#if ATOMIC_PROFILING
if (profiler != null)
csi_Atomic_Profiler_EndBlock(profiler);
#endif
}
public static void BeginBlock(string name, uint color = 0xffffecb3,
ProfilerBlockStatus status = ProfilerBlockStatus.ON,
[CallerFilePath] string file = "",
[CallerLineNumber] int line = 0)
{
var profiler = AtomicNET.Context.GetProfiler();
if (profiler != null)
csi_Atomic_Profiler_BeginBlock(profiler, name, file, line, color, (byte)status);
}
public static void EndBlock()
{
var profiler = AtomicNET.Context.GetProfiler();
if (profiler != null)
csi_Atomic_Profiler_EndBlock(profiler);
}
[DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private static extern void csi_Atomic_Profiler_BeginBlock(IntPtr self, string name, string file, int line, uint argb, byte status);
[DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private static extern void csi_Atomic_Profiler_EndBlock(IntPtr self);
}
}