mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-24 02:28:01 +02:00
Initial checkin
This commit is contained in:
parent
c74712dad9
commit
078564ac9e
3242 changed files with 1616395 additions and 0 deletions
95
IDE/mintest/minlib/src/System/Diagnostics/Profiler.bf
Normal file
95
IDE/mintest/minlib/src/System/Diagnostics/Profiler.bf
Normal file
|
@ -0,0 +1,95 @@
|
|||
using System.Threading;
|
||||
|
||||
namespace System.Diagnostics
|
||||
{
|
||||
enum ProfilerScope
|
||||
{
|
||||
Thread,
|
||||
Process
|
||||
}
|
||||
|
||||
struct ProfileId : int32
|
||||
{
|
||||
}
|
||||
|
||||
class Profiler
|
||||
{
|
||||
public enum Priority
|
||||
{
|
||||
Low,
|
||||
Normal,
|
||||
High
|
||||
}
|
||||
|
||||
static int32 gProfileId = 1;
|
||||
|
||||
public struct AutoLeave
|
||||
{
|
||||
//Profiler mProfiler;
|
||||
|
||||
public this(/*Profiler profiler*/)
|
||||
{
|
||||
//mProfiler = profiler;
|
||||
}
|
||||
|
||||
void Dispose()
|
||||
{
|
||||
Profiler.LeaveSection();
|
||||
}
|
||||
}
|
||||
|
||||
static Result<ProfileId> StartSampling(int32 threadId, StringView profileDesc)
|
||||
{
|
||||
//int32 curId = Interlocked.Increment(ref gProfileId);
|
||||
int32 curId = gProfileId++;
|
||||
|
||||
String str = scope String();
|
||||
str.Append("StartSampling\t");
|
||||
curId.ToString(str);
|
||||
str.Append("\t");
|
||||
threadId.ToString(str);
|
||||
str.Append("\t");
|
||||
str.Append(profileDesc);
|
||||
Internal.ProfilerCmd(str);
|
||||
return (ProfileId)curId;
|
||||
}
|
||||
|
||||
public static void StopSampling(ProfileId profileId)
|
||||
{
|
||||
String str = scope String();
|
||||
str.Append("StopSampling\t");
|
||||
((int32)profileId).ToString(str);
|
||||
Internal.ProfilerCmd(str);
|
||||
}
|
||||
|
||||
public static Result<ProfileId> StartSampling(Thread thread, StringView profileDesc = default)
|
||||
{
|
||||
return StartSampling(thread.Id, profileDesc);
|
||||
}
|
||||
|
||||
public static Result<ProfileId> StartSampling(StringView profileDesc = default)
|
||||
{
|
||||
return StartSampling(0, profileDesc);
|
||||
}
|
||||
|
||||
public static void ClearSampling()
|
||||
{
|
||||
Internal.ProfilerCmd("ClearSampling");
|
||||
}
|
||||
|
||||
public void Mark()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static AutoLeave EnterSection(StringView name, Priority priority = Priority.Normal)
|
||||
{
|
||||
return AutoLeave();
|
||||
}
|
||||
|
||||
public static void LeaveSection()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue