Inlining?

  • Thread starter Thread starter Tony Vitonis
  • Start date Start date
T

Tony Vitonis

From what I can tell, VB.NET doesn't allow programmers to say
explicitly that they want a function to be inlined. Now, I'm a big fan
of factoring out duplicate code, but I don't want to do too much of it
in VB if there's going to be a noticeable performance hit. So:

1. Does the VB compiler sometimes inline simple functions?
2. Is there much of a performance hit on a function call?

Thanks.
 
1. Not that I know of, although it does inline constants from classes
instantiated within the calling class.
2. Not really. Instantiation is the real bugger in software, as
instantiating objects is the more expensive part.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
Tony,
1. Does the VB compiler sometimes inline simple functions?
Neither VB.NET nor C# inline simple functions, per se.

The JIT compiler in the .NET runtime will inline simple functions when it
loads & compiles your code (at runtime)! The benefit of this approach is
that you will gain new optimizations by installing a new version of the
runtime, rather then needed to physically recompile your programs. This of
course assumes you allow your program to run on the new version of the
runtime (its configurable via the configuration files).
2. Is there much of a performance hit on a function call?
I don't believe there is a noticeable performance hit. Generally you should
write good code first (avoid duplicate code). Then when you actually have a
performance problem you can refactor that routine so it performs better.

http://www.refactoring.com

The following articles provide information on writing .NET code that
performs well.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/fastmanagedcode.asp

http://msdn.microsoft.com/library/d...y/en-us/dndotnet/html/highperfmanagedapps.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/vbnstrcatn.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchperfopt.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/dotnetperftechs.asp

Hope this helps
Jay
 
Back
Top