471,319 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

C# optimization trick

Hi,

I've read that the if/else statement, or get/set accessor, can be
compiled inline by the C# compiler if they are small enough.

Have you seen any documentation that 'summarized' all thoses
optimizations tricks? I would like to be aware of all tips and trick
that should be used as good programming habits that make any software
coding optimized. I remember that in VB6 there was a lot of
optimization tips.

So my question does not concern solving bottleneck inside an algorithm,
but tricks related on the language itself.

If you have any idea, that would be very appreciated, thanks!

Regards,
Marty
Jan 13 '06 #1
5 4070
Check out some of the Patterns and Practices whitepapers. Here's a good one:

http://msdn.microsoft.com/practices/...l/scalenet.asp

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Marty" wrote:
Hi,

I've read that the if/else statement, or get/set accessor, can be
compiled inline by the C# compiler if they are small enough.

Have you seen any documentation that 'summarized' all thoses
optimizations tricks? I would like to be aware of all tips and trick
that should be used as good programming habits that make any software
coding optimized. I remember that in VB6 there was a lot of
optimization tips.

So my question does not concern solving bottleneck inside an algorithm,
but tricks related on the language itself.

If you have any idea, that would be very appreciated, thanks!

Regards,
Marty

Jan 13 '06 #2
Hi Peter,

I had a look and it seem to have a lot of content, I'll read it all.

Thank you very much :)
Marty

Peter Bromberg [C# MVP] wrote:
Check out some of the Patterns and Practices whitepapers. Here's a good one:

http://msdn.microsoft.com/practices/...l/scalenet.asp

Peter

Jan 13 '06 #3
Marty <xm******@hotmail.com> wrote:
I've read that the if/else statement, or get/set accessor, can be
compiled inline by the C# compiler if they are small enough.
No, they get inlined by the JIT - that's slightly different. In
particular, it's not a C# trick, it would happen in VB.NET too, for
instance.
Have you seen any documentation that 'summarized' all thoses
optimizations tricks? I would like to be aware of all tips and trick
that should be used as good programming habits that make any software
coding optimized. I remember that in VB6 there was a lot of
optimization tips.

So my question does not concern solving bottleneck inside an algorithm,
but tricks related on the language itself.

If you have any idea, that would be very appreciated, thanks!


I think it's more a case of *platform* "tricks" than language tricks.
For instance, you really ought to (and probably already do) know about
StringBuilder:
http://www.pobox.com/~skeet/csharp/stringbuilder.html

Is that the kind of thing you're after? I'll think about some more.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 13 '06 #4
"Marty" <xm******@hotmail.com> wrote in message
news:J0Sxf.54609$km.7484@edtnps89...
Hi,

I've read that the if/else statement, or get/set accessor, can be compiled
inline by the C# compiler if they are small enough.

Have you seen any documentation that 'summarized' all thoses optimizations
tricks? I would like to be aware of all tips and trick that should be
used as good programming habits that make any software coding optimized.
I remember that in VB6 there was a lot of optimization tips.


1. It's the JIT compiler that does it at runtime from the IL bytes not the
C# compiler.
2. How does it help you to optimize your accessors? Surely they already
contain as much code as they need to and no more.
3. As a general guidline you should use methods rather than properties where
a lot of work is involved. It's not a rule but people will assume that
property access is always efficient.
Jan 15 '06 #5
Hi Jon,

Thanks for the correction about C# compiler and JIT. Yes, this is the
kind of optimization trick I am looking for.

Regards
Marty

Jon Skeet [C# MVP] wrote:
Marty <xm******@hotmail.com> wrote:
I've read that the if/else statement, or get/set accessor, can be
compiled inline by the C# compiler if they are small enough.

No, they get inlined by the JIT - that's slightly different. In
particular, it's not a C# trick, it would happen in VB.NET too, for
instance.

Have you seen any documentation that 'summarized' all thoses
optimizations tricks? I would like to be aware of all tips and trick
that should be used as good programming habits that make any software
coding optimized. I remember that in VB6 there was a lot of
optimization tips.

So my question does not concern solving bottleneck inside an algorithm,
but tricks related on the language itself.

If you have any idea, that would be very appreciated, thanks!

I think it's more a case of *platform* "tricks" than language tricks.
For instance, you really ought to (and probably already do) know about
StringBuilder:
http://www.pobox.com/~skeet/csharp/stringbuilder.html

Is that the kind of thing you're after? I'll think about some more.

Jan 16 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Magnus Lie Hetland | last post: by
9 posts views Thread by Rune | last post: by
2 posts views Thread by Eugene | last post: by
93 posts views Thread by roman ziak | last post: by
15 posts views Thread by Spidey | last post: by
21 posts views Thread by mjbackues at yahoo | last post: by
5 posts views Thread by wkaras | last post: by
20 posts views Thread by Ravikiran | last post: by

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.