Here's a very quick knock up of a function timer, very basic and I put it here for improvement and discussion. Just add this class in your project somewhere and away you go.
/// <summary>
/// //Class to time the execution of functions for testing and comparisons
/// </summary>
public class FunctionTimer
{
public FunctionTimer()
{
//
// TODO: Add constructor logic here
//
}
private double _startTicks;
private double _endTicks;
private double _totalTime;
public void Start()
{
_startTicks = Convert.ToDouble(DateTime.Now.Ticks);
}
public void Stop()
{
_endTicks = Convert.ToDouble(DateTime.Now.Ticks);
_totalTime = (_endTicks - _startTicks)/10000000.0;
}
public string ElapsedTime
{
get
{
return "Total Elapsed Time = " + _totalTime.ToString() + " seconds\n";
}
}
An example in acad -
[CommandMethod("TIMERTEST")]
public static void TestTimer()
{
FunctionTimer timer = new FunctionTimer();
timer.Start();
Editor ed =
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
int i = 0;
int j = 1;
int k = 2;
for(int a = 0; a < 1000; a++)
{
ed.WriteMessage("\nTesting {0} {1} {2}:",i += 3,j += 3,k += 3);
}
timer.Stop();
ed.WriteMessage(timer.ElapsedTime);
}
enjoy!