the act of recording the timings will always have an impact on code speed. sounds like the timing calls are the cause of the erroneous results. can't remember how truetime attaches to code but if it does it before compiling into IL it's probably doing it in different places or ways.
as an aside, it is highly amusing that a product truetime gives _untrue_ results ;) chris: I always thought the use of braces and semi colons was to show humour in code: ;} -----Original Message----- From: Jim Murphy [mailto:[EMAIL PROTECTED]] Sent: 22 January 2003 19:04 To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Braces make code execution faster? No braces don't effect runtime performance at all. They are a language thing and don't survive the compilation to IL code. Write a class with these methods... public void foo() { for (int i = 0; i < 100000; ++i) Console.WriteLine("foo"); } public void bar() { for (int i = 0; i < 100000; ++i) { Console.WriteLine("bar"); } } Run ildams.exe and load your assembly. Inspect the methods and notice that exactly the same IL is produced. That code is compiled into native x86 instructions at runtime so given the same IL the same x86 instructions should be generated and the code for both methods should be the same. Jim Murphy Mindreef, LLC http://www.mindreef.com > -----Original Message----- > From: Moderated discussion of advanced .NET topics. [mailto:ADVANCED- > [EMAIL PROTECTED]] On Behalf Of Edward Ferron > Sent: Wednesday, January 22, 2003 1:06 PM > To: [EMAIL PROTECTED] > Subject: [ADVANCED-DOTNET] Braces make code execution faster? > > I am using the NuMega/Compuware Truetime tool to measure performance in a > simple console application. I have tested the following code several > times > with consistent results > > // The following code is faster > > for(int i = 0; i < 10000; ++i) > { > // do anything here ... Console.WriteLine, assign i to another variable, > it doesn't matter.... > } > > > // than this code > > > for (int = i; i < 10000; ++i) > // do anything here ... Console.WriteLine, assign i to another variable, > it doesn't matter.... > > > Do the braces speed up code execution? Why/how? > > You can read messages from the Advanced DOTNET archive, unsubscribe from > Advanced DOTNET, or > subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.
