473,387 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Macros too slow !

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.

Mar 5 '06 #1
1 1136
I had the same problem -- my work around was to right click the Macro and
then select Run (I used to just double click).

"Cerebrus" <zo*****@sify.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
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.

Mar 7 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Chris Reedy | last post by:
For everyone - Apologies for the length of this message. If you don't want to look at the long example, you can skip to the end of the message. And for the Python gurus among you, if you can...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
16
by: mike420 | last post by:
Tayss wrote: > > app = wxPySimpleApp() > frame = MainWindow(None, -1, "A window") > frame.Show(True) > app.MainLoop() > Why do you need a macro for that? Why don't you just write
37
by: michele.simionato | last post by:
Paul Rubin wrote: > How about macros? Some pretty horrible things have been done in C > programs with the C preprocessor. But there's a movememnt afloat to > add hygienic macros to Python. Got any...
12
by: Steven T. Hatton | last post by:
I've noticed in different places where people who write #MACROS use a null do/while. For example: do { POINTER = new CONSTRUCTOR; \ if (POINTER == 0) { errno = ENOMEM; ACE_THROW_INT...
3
by: Stephen Sprunk | last post by:
On a project I'm working on, I ran across the following macros: /* assume s is struct stream *, s->p is char, v is unit16_t or uint32_t */ #define in_uint16_le(s,v) { v = *((s)->p++); v +=...
3
by: Cerebrus | last post by:
Hi all, I posted this topic in microsoft.public.dotnet.general but received no reply. So hoping for a reply here... I'm trying to use a macro in VS 2003 to insert a code snippet in various...
17
by: Alex Buell | last post by:
A previous thread about macros just reminded me to ask this. I have avoided using macros and defined some constants i.e.: const int BYTES_PER_TRACK = 10 * 256; const int TRACK0_SS_OFFSET = 0;...
33
by: Robert Seacord | last post by:
When writing C99 code is a reasonable recommendation to use inline functions instead of macros? What sort of things is it still reasonable to do using macros? For example, is it reasonable to...
5
by: sturlamolden | last post by:
Hello The Lisp crowd always brags about their magical macros. I was wondering if it is possible to emulate some of the functionality in Python using a function decorator that evals Python code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.