Reputation: 11794
quick question: are blank lines in c# asp.net code bad for performance because of the larger file size? or is this taken care of through compilation? What compressing techniques are available for this case?
Upvotes: 1
Views: 1298
Reputation: 1795
C# Compiler wont consider empty line breaks. These are omitted by C# Compiler. This will Not affect your code performance.
Hope this will help you...
Upvotes: 0
Reputation: 1365
Edit (thanks @Jigar):
There will be no difference to execution times for compiled code.
An inordinate amount of white space/comments may take the compiler a fraction longer to tokenize, but the C# compiler doesn't care about white space that's not syntactically significant.
On the presentation layer: The consideration is probably for transmission and rendering rather than the server side impact.
A smaller page will transfer and render faster.
There are a number of 'minification' stratergies out there, but any performance gains will certainly depend on a number of other factors such as device, connection, load, page size, etc.
It is somewhat common to serve compressed resources (scripts, json data, even HTML) and have the client unpack and render resulting in less transmission overhead. Like this
A question worth asking: Are there other areas that will provide more gain for less work?
There are many page speed tools out there which will analyse performance from a client perspective and make reasonable recommendations. Some web based ones:
Upvotes: 1
Reputation: 5987
Well if you are talking about having white spaces in your Code behind or C# code file then not they will not be counted by your compilation.
Modern day compilers e.g .net framework compiler will remove the white spaces and other comments and punctuation while compiling your code.
This process is also called tokenization; this removes unwanted stuff from your code before compiling. Remove meant not remove from the code base file but do not consider them for compilation.
SO in your code when you have ";" the compiler consider it as end of line for compilation and when the next character meets it consider it as new line for compilation.
Upvotes: 4
Reputation: 39501
Blank line is actually 1 or two characters (if you are not explicitly using spaces or tabs throughout the line(:))), so it would not make file notably larger even if size was performance degrading.
Upvotes: 0