473,378 Members | 1,420 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,378 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 4153
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.