Created
February 24, 2017 15:51
-
-
Save alfeg/0eca75411638dd3d1d8d6c899ab4ecbe to your computer and use it in GitHub Desktop.
Jerbrain.profile wrappers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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