I would like to make better some methods in C# or C++ or C.
To measure time I can use Stopwatch class, but additionally I would like to measure memory reserved by exterminated code. Do you know any class or method which has similar properties to MemoryMeasure class used in code below?
Stopwatch s1 = Stopwatch.StartNew();
MemoryMeasure m1 = MemoryMeasure.Start();
for (int i = 0; i < m; i++)
{
//some compute
//for example
//var x = new LargeObject(new SmallObject(), 45);
//some compute
//some compute
}
m1.Stop();
s1.Stop();
Console.Writeline("Your code was executed in " + s1.ElapsedMilliseconds + "ms");
Console.Writeline("Your code ate " + m1.UsedMemory + "MB of memory");
You will need to use a memory profiler – there are several free and commercial tools.
dotTrace and Ants memory profiler are two popular commercial ones.
There are a few free ones as well.