C
Cerebrus
Hi all,
I'm trying to use a macro in VS 2003 to insert a code snippet in
various sections of my code. This code will help me to test the time
taken for any particular action to be performed.
The problem is that it takes nearly 30 seconds for it to be executed,
after I press my Keyboard shortcut, and to see the results in my code
window. I'm new to using macros in the IDE, so I have no idea if the
macro is actually being compiled and then executed or what !
The macro code is as follows :
=========================
Sub TimeSpanCheck()
Dim objDoc As Document = DTE.ActiveDocument
Dim mySel As TextSelection = objDoc.Selection
mySel.Text = "Console.Write(""Time before the action :"")"
mySel.NewLine()
mySel.Text = "Dim oldTime As DateTime = DateTime.Now"
mySel.NewLine()
mySel.Text = "Console.WriteLine(""{0:HH:mm:ss.fff}"", oldTime)"
mySel.NewLine()
mySel.Text = " ' "
mySel.NewLine()
mySel.Text = " ' My actions here"
mySel.NewLine()
mySel.Text = " ' "
mySel.NewLine()
mySel.Text = "Console.Write(""Time after the action :"")"
mySel.NewLine()
mySel.Text = "Dim newTime As DateTime = DateTime.Now"
mySel.NewLine()
mySel.Text = "Console.WriteLine(""{0:HH:mm:ss.fff}"", newTime)"
mySel.NewLine()
mySel.Text = "Dim Diff As TimeSpan = newTime.Subtract(oldTime)"
mySel.NewLine()
mySel.Text = "Console.WriteLine(""Time taken for process :
{0}min:{1}secs:{2}millisecs"", Diff.Minutes, Diff.Seconds,
Diff.Milliseconds)"
mySel.NewLine()
objDoc.Save()
End Sub
=========================
Am I doing something wrong here, or is this time taken normal ? Also,
is there a way to speed it up (something like precompiling the code.)
Any comments are appreciated,
Regards,
Cerebrus.
I'm trying to use a macro in VS 2003 to insert a code snippet in
various sections of my code. This code will help me to test the time
taken for any particular action to be performed.
The problem is that it takes nearly 30 seconds for it to be executed,
after I press my Keyboard shortcut, and to see the results in my code
window. I'm new to using macros in the IDE, so I have no idea if the
macro is actually being compiled and then executed or what !
The macro code is as follows :
=========================
Sub TimeSpanCheck()
Dim objDoc As Document = DTE.ActiveDocument
Dim mySel As TextSelection = objDoc.Selection
mySel.Text = "Console.Write(""Time before the action :"")"
mySel.NewLine()
mySel.Text = "Dim oldTime As DateTime = DateTime.Now"
mySel.NewLine()
mySel.Text = "Console.WriteLine(""{0:HH:mm:ss.fff}"", oldTime)"
mySel.NewLine()
mySel.Text = " ' "
mySel.NewLine()
mySel.Text = " ' My actions here"
mySel.NewLine()
mySel.Text = " ' "
mySel.NewLine()
mySel.Text = "Console.Write(""Time after the action :"")"
mySel.NewLine()
mySel.Text = "Dim newTime As DateTime = DateTime.Now"
mySel.NewLine()
mySel.Text = "Console.WriteLine(""{0:HH:mm:ss.fff}"", newTime)"
mySel.NewLine()
mySel.Text = "Dim Diff As TimeSpan = newTime.Subtract(oldTime)"
mySel.NewLine()
mySel.Text = "Console.WriteLine(""Time taken for process :
{0}min:{1}secs:{2}millisecs"", Diff.Minutes, Diff.Seconds,
Diff.Milliseconds)"
mySel.NewLine()
objDoc.Save()
End Sub
=========================
Am I doing something wrong here, or is this time taken normal ? Also,
is there a way to speed it up (something like precompiling the code.)
Any comments are appreciated,
Regards,
Cerebrus.