1、内存
var start = GC.GetTotalMemory(true);
// todo:待测量的操作
GC.Collect();
GC.WaitForFullGCComplete();
var end = GC.GetTotalMemory(true);
var useMemory = end - start;
2、时间
var watch = new Stopwatch();
watch.Start();
// todo:待测量的操作
watch.Stop();
var useTime = watch.ElapsedMilliseconds;