Skip to content

Instantly share code, notes, and snippets.

@alfeg
Created February 24, 2017 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfeg/0eca75411638dd3d1d8d6c899ab4ecbe to your computer and use it in GitHub Desktop.
Save alfeg/0eca75411638dd3d1d8d6c899ab4ecbe to your computer and use it in GitHub Desktop.
Jerbrain.profile wrappers
public class DotMemoryProfile : IDisposable
{
public DotMemoryProfile()
{
if (MemoryProfiler.IsActive && MemoryProfiler.CanControlAllocations)
MemoryProfiler.EnableAllocations();
MemoryProfiler.Dump();
}
public void Dispose()
{
MemoryProfiler.Dump();
if (MemoryProfiler.IsActive && MemoryProfiler.CanControlAllocations)
MemoryProfiler.DisableAllocations();
}
}
public class DotTraceProfile : IDisposable
{
private readonly string @group;
public DotTraceProfile(string group = null)
{
this.@group = @group;
if (PerformanceProfiler.IsActive)
{
if (group != null)
{
PerformanceProfiler.BeginGroup(this.@group);
}
else
{
PerformanceProfiler.Begin();
PerformanceProfiler.Start();
}
}
}
public void Dispose()
{
if (PerformanceProfiler.IsActive)
{
if (this.@group != null)
{
PerformanceProfiler.EndGroup();
}
else
{
PerformanceProfiler.Stop();
PerformanceProfiler.EndSave();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment