Skip to content

Commit

Permalink
Static profiler BeginBlock and EndBlock methods for c#
Browse files Browse the repository at this point in the history
  • Loading branch information
rokups committed Jun 29, 2017
1 parent d826df8 commit bedf501
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
23 changes: 22 additions & 1 deletion Script/AtomicNET/AtomicNET/Core/Profiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,32 @@ public static void Block(string name, Action block, uint color = 0xffffecb3,
#endif
block();
#if ATOMIC_PROFILING
profiler?.EndBlock();
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);
}
}
3 changes: 3 additions & 0 deletions Script/Packages/Atomic/Core.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"CSharp" : {
"Object" : {
"UnsubscribeFromAllEvents" : []
},
"Profiler": {
"EndBlock" : []
}
}
},
Expand Down
10 changes: 10 additions & 0 deletions Source/AtomicNET/NETNative/NETCInterop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,16 @@ namespace Atomic
warned = true;
ATOMIC_LOGWARNING("Engine is built without profiler support.");
}
#endif
}

ATOMIC_EXPORT_API void csi_Atomic_Profiler_EndBlock(Profiler* profiler)
{
#if ATOMIC_PROFILING
if (!profiler)
return;

profiler->EndBlock();
#endif
}
}
Expand Down

0 comments on commit bedf501

Please sign in to comment.