Created
June 8, 2013 07:36
-
-
Save fresky/5734426 to your computer and use it in GitHub Desktop.
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 static double TimeWatcher() | |
{ | |
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); | |
watch.Start(); | |
// operations under test start | |
// ... | |
// operation under test stop | |
watch.Stop(); | |
var useTime = (double) watch.ElapsedMilliseconds/1000; | |
return useTime; | |
} | |
public static long MemoryWatcher() | |
{ | |
long start = GC.GetTotalMemory(true); | |
// operations under test start | |
// ... | |
// operation under test stop | |
GC.Collect(); | |
GC.WaitForFullGCComplete(); | |
long end = GC.GetTotalMemory(true); | |
long useMemory = (end - start)/(1024*1024); | |
return useMemory; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment