473,387 Members | 1,606 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.

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 4156
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Magnus Lie Hetland | last post by:
I'm working on a project (Atox) where I need to match quite a few regular expressions (several hundred) in reasonably large text files. I've found that this can easily get rather slow. (There are...
9
by: Rune | last post by:
Is it best to use double quotes and let PHP expand variables inside strings, or is it faster to do the string manipulation yourself manually? Which is quicker? 1) $insert = 'To Be';...
2
by: Eugene | last post by:
I am trying to set query optimization class in a simple SQL UDF like this: CREATE FUNCTION udftest ( in_item_id INT ) SPECIFIC udftest MODIFIES SQL DATA RETURNS TABLE( location_id INT,...
12
by: WantedToBeDBA | last post by:
Hi all, db2 => create table emp(empno int not null primary key, \ db2 (cont.) => sex char(1) not null constraint s_check check \ db2 (cont.) => (sex in ('m','f')) \ db2 (cont.) => not enforced...
93
by: roman ziak | last post by:
I just read couple articles on this group and it keeps amazing me how the portability is used as strong argument for language cleanliness. In my opinion, porting the program (so you just take the...
15
by: Spidey | last post by:
is there any ulternative metho to optimize the following piece of code (for loop) main() { int i,j; for(i=0;i<40000000;i++) j=1; }
21
by: mjbackues at yahoo | last post by:
Hello. I'm having a problem with the Visual Studio .net (2003) C++ speed optimization, and hope someone can suggest a workaround. My project includes many C++ files, most of which work fine...
5
by: wkaras | last post by:
I've compiled this code: const int x0 = 10; const int x1 = 20; const int x2 = 30; int x = { x2, x0, x1 }; struct Y {
20
by: Ravikiran | last post by:
Hi Friends, I wanted know about whatt is ment by zero optimization and sign optimization and its differences.... Thank you...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.