Inline function.....

  • Thread starter Thread starter Allen Smith
  • Start date Start date
A

Allen Smith

Is there any inline function concept of C language in .Net Framework 1.1 and
VB.Net Language?

A Smith
 
Huh?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
 
Allen Smith said:
Is there any inline function concept of C language in .Net Framework 1.1
and
VB.Net Language?

Why would such a thing be required?

John Saunders
 
You mean inlining a function as an optimization? The JIT compiler can
do this when compiling the program. There are no directives available
in the language to "hint" at the optimization. Any non-virtual method
call with less than 32 bytes of IL is going to be a candidate for
inlining.
 
I have written function which has one/two lines of code. Primarily like some
string manipulation. I feel now this is an additional overhead to make a
call to the function. If I can make these functions as inline, it would be
better.
Thanks,
Allen
 
Allen Smith said:
I have written function which has one/two lines of code. Primarily like
some
string manipulation. I feel now this is an additional overhead to make a
call to the function. If I can make these functions as inline, it would be
better.

How do you know that it would be better? Why would it not be worse? Did you
measure?

John Saunders
 
I did not run any performance test.

It makes sense for me there will be additional CPU cycles to call functions.

If I write the code in all the places instead of function may be a good
approach. Just a thought.

Thanks for your all replies.

Allen
 
Allen Smith said:
I did not run any performance test.

It makes sense for me there will be additional CPU cycles to call
functions.

What makes sense is not always so. In this particular case, compilers have
been better at this than humans for the past decade or so. For at least that
long it has been a waste of time to specify inlining. In fact, doing so can
prevent some compilers from doing a good job deciding which code should be
inline.
If I write the code in all the places instead of function may be a good
approach. Just a thought.

I find that it is a very bad idea to solve problems which do not exist.
Therefore, before I optimize my code, I make sure that it works (as
non-working code is usually worse than slow code, since I don't write
horribly slow code any more). Once it works, I then look to see if there are
performance problems. If so, I then look for the solution to those problems.

It may never turn out that the solution to a performance problem involves
inlining.

John Saunders
 
Thanks for your inputs.
allen

John Saunders said:
What makes sense is not always so. In this particular case, compilers have
been better at this than humans for the past decade or so. For at least that
long it has been a waste of time to specify inlining. In fact, doing so can
prevent some compilers from doing a good job deciding which code should be
inline.


I find that it is a very bad idea to solve problems which do not exist.
Therefore, before I optimize my code, I make sure that it works (as
non-working code is usually worse than slow code, since I don't write
horribly slow code any more). Once it works, I then look to see if there are
performance problems. If so, I then look for the solution to those problems.

It may never turn out that the solution to a performance problem involves
inlining.

John Saunders
 
Back
Top