C# - Comments Slow Down The Execution Time Of Webpages?
Nov 5, 2010
This might be a pretty strange question in the eyes of some of you out here, but I really wonder if comments in my code will slow down the execution time of the pages I make.I have some Classes / WebControls that required alot of comments to make everything clear and quickly readable to other people that will have to deal with my code and now wonder how ASP.Net deals with my comments. Will comments be stripped from my code at compile time or how is this all done?I should be more specific: I mean comments in my code-behind in C#.
I have developed an application that interacts with IBM ClearQuest. The problem is that when I run everything locally, such as, run the webservice local and then ASP page local everything is at the speed I expect. When I post the webservice (precompiled) to the server and run the web page through the server, the call to the webmethod takes at least 10x the amount of time it should. I dont know why this is happening. I made a console application that has the function in question and execute it on the server and locally and they both return the same amounts of time (roughly) its just when I move to executing via the webmethod everything grinds to a snails pace. Any ideas? This happens every time not just on the first call.
WebMethod:
Public Function RetrieveQueryResults(ByRef cqSession As ClearQuestOleServer.Session, _ ByVal sqlStmt As String) As List(Of SearchResultsSingleIssue) Dim numCols As Integer, status As Integer, columnIdx As Integer Dim numRows As Integer Dim rowContents As String = "" Dim colValue As New Object Dim colLabel As New Object Dim allitems As New List(Of SearchResultsSingleIssue) Dim results As New SearchResultsSingleIssue Dim cqResultSet As ClearQuestOleServer.OAdResultset cqResultSet = cqSession.BuildSQLQuery(sqlStmt) cqResultSet.Execute() ' Get the number of columns returned by the query. numRows = 0 numCols = cqResultSet.GetNumberOfColumns status = cqResultSet.MoveNext ' Collect query results. Do While status = AD_SUCCESS results = New SearchResultsSingleIssue numRows = numRows + 1 For columnIdx = 1 To numCols colLabel = cqResultSet.GetColumnLabel(columnIdx) colValue = cqResultSet.GetColumnValue(columnIdx) 'Make sure that we dont pass along a null reference If colValue = Nothing Then colValue = "" End If Select Case colLabel Case "ID" results.IssueID = colValue Case "HEADLINE" results.Headline = colValue Case "NAME" results.State = colValue Case "OE_CONTACT" results.OEContact = colValue Case "DESCRIPTION" results.Further_Description = colValue Case "PRODUCT_NAME" results.Product_Name = colValue Case "FUNCTIONAL_AREA" results.Functional_Area = colValue Case "SUBTOPIC" results.Subtopic = colValue Case "FOUND_VERSION" results.Found_In = colValue Case "SCHEDULED_VERSION" results.Scheduled_For = colValue Case "SYMPTOMS" results.Symptoms = colValue Case "AFFECTED_SYSTEMS" results.Affected_System_Types = colValue Case "ISSUE_TYPE" results.Issue_Type = colValue Case "ASSIGNED_TO" results.Assigned_Developer = colValue Case "TESTED_BY" results.Assigned_Tester = colValue Case "BUILT_VERSION" results.Built_In = colValue Case "TESTED_VERSION" results.Tested_In = colValue Case "NOTES_LOG" results.Notes_Log = colValue Case "CUSTOMER_SEVERITY" results.Severity = colValue Case "PRIORITY" results.Priority = colValue End Select Next columnIdx ' Add the query row result to the compiled list of all rows. allitems.Add(results) status = cqResultSet.MoveNext Loop Return allitems End Function
i have developed an ERP in asp.net 3.5. The problem is that when published and as well as during development, the execution speed of page is very slow. I have off the compilation mode in web.config and also get all the data in page load and then filter it using Dataview rowfilter property but i can't get much better speed.
Select a from tbl_abc where id in ( select id from tbl_xyz where mainid = 12)
When I am executing this query, it is taking 1-2 seconds to execute, but when I am using the same query in stored procedure, the below query is taking more than 5 minute:
If(Select a from tbl_abc where id in ( select id from tbl_xyz where mainid = 12)) BEGIN -- CREATE TEMPORARY TABLE [Say: #temp1] #temp1 => Select a from tbl_abc where id in ( select id from tbl_xyz where mainid = 12) inserting the same value in the temp table drop #temp1 END
what could be the reason of this? and how can I resolve this? I am running the SP from asp.net
I would like to check how long an ASP.NET page takes to execute (server stuff obviously, not interested in how long it takes to throw the results down the line and for the browser to render them at this stage).
Having done some searching, I came across http:[URL] which shows how to do just this. Trouble is, it doesn't work for me. I copied the code exactly, but the execution time is always zero.
I tried enabling tracing, and that showed an elapsed time between Page_Init and Page_PreRender, but the values returned by Environment.TickCount were exactly the same in both events, so the elapsed time was 9obviously) zero.
I need to find out the query execution time from the front end .Where should I insert the code for that.
I am using the bleow query:
OracleConnection con = new OracleConnection(ConnStr); con.Open(); OracleCommand cmd = new OracleCommand("Stored_Proc",con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(); .................... ................ OracleDataAdapter oda = new OracleDataAdapter (cmd);
I need to capture the amount of time that ASP.net takes to execute each page request in my application, but I need to exclude any network latency. I am currently capturing render times by using the StopWatch class and starting the stopwatch during the OnInit method of the page lifecycle and stopping it after the Unload method completes. It seems that the Unload method includes the time it takes send the request to the client, thus including any internet/network latency. What is the last possible point I could stop the stopwatch in the Page Life Cycle that would not include the time it takes to send the request to the client. Would it be directly before the Unload event?
Related question: Does ASP.net finish building the response before it starts sending to the client? Or does it start sending asynchronously, while the response is being formed?
I am using ASP.Net 2.0 with IIS 5 currently.
I have this code in a class that all of my pages inherit from:
I tried capturing the execution time at the end of the OnRender method, at the start of the OnUnload method and at the end of the OnUnload method. In all three cases the difference in times was at most 1 millisecond. Even when testing this from a client in Europe to a server in the USA, the times were identical.
In application all sql connection close properly, Also when user log out its connection close still sql process memory increase in RAM and after some time Application slow down.
So I have a RadPanelBar, and within that a RadTreeView. On a node click event I want so update some control.. for now I am just trying to update a textbox. It works fine except that the first time I click on a child node it takes a very long time to update the control.. Just a simple text change. I set a break point in my function and I noticed that it is taking long to fire the OnNodeClick event.. If I click a parent node in the tree view it loads fine on the first click. Also, after the first time I've clicked it.. it loads quickly.. If I refresh the page, it is slow on the first click again.. Is there something I am missing.. Is the structure of my HTML inappropriate for these AJAX calls? I feel like this is a really simple example that should work..
EDIT: I updated my code according to this article, [URL] , and the problem persisted... again it only happens the first time..
EDIT: Just to clarify, by updating according to that article, I mean that I removed all the tables and relative widths and replaced them with css positioning and fixed widths.. the problem only happens the first time.. and it only happens sometimes.. quite a few times i thought i solved the problem as it would start responding quickly.. but then after I change my .aspx and change it back (even to the exact same thing when it was working quickly).. I get the same problem..
EDIT: So, I removed the AJAX component.. and setup the control so that it does a PostBack.. and it still takes long to hit my break point.. so it seems that its not an AJAX issue... but for some reason my events are taking long to fire..
EDIT: So I followed the advice on this post and I used the webservices to do my binding and handle everything from the client side code.. All seemed to be ok until I decided that I wanted to return nodes from my webservice that could also be expanded.. So in my webservice I set the ExpandMode of my RadTreeNodeData object to Webservice.. and it renders the data correctly when I expand the child nodes.. However now I see the same problem from before where some calls take 20-30 seconds.. It takes 20-30 seconds to even hit the break point in my webservice.. Should I use the OnClientNodeExpand event instead?
My web site seems to be running quick. I have not deployed my web site yet, so I am the only one using it right now. The problem I have is if I am testing out the site and then I stop using it for a short period of time, when I come back the web site takes about 8-10 seconds to startup again. I did not rebuild the site I just simply stopped using it for a short period of time. It seems like after a short period of time I have to 'wake it up' again. Is this normal? How can I prevent this?
We have an asp.net website running on IIS 6 Windows 2003. When ever we upload a class file to the App_Code folder our whole site goes down temporarily until, what I assume, compilation is complete. Has anyone else experienced this? Any other file we upload it does not do this only our class files.
We recently migrated to v4 of .net. We are running iis 7 in integrated mode. When the site first starts its slow. I get that - it compiles for the first time. The odd thing is then we will go to certain pages and it seems to compile again. The next time i go that page its very fast. Nothing exceptional with the second page - but once that is hit the rest of the site is fast.
When we include Javascript files in our aspx files. either we write all the Javascript code in the Head section of aspx or we link to an external Javascript file.
So when the clinet makes a call to that page. Does that mean that all the Javascript will be loaded on the client side?
If that is the case then does not that mean that it will slow down the loading of page as all the Javascript has to be loaded on the client machine?
in the web.config file of an application - so that file uploads of 10mb are allowed. The default - shown in the web.config.comments file - is 4096 or 4mb Today a user uploaded a file that was 4.55 mb and the app fell over. The server event log shows this warning:Post size exceeded allowed limits About 10 minutes later another email was sent with a 3.33 mb attachment. Again, it fell over and this time the server event log shows:
HttpException ... Request timed out
As it happens, on both occasions the files were uploaded to the server correctly and all the emails got sent - according to log files on the Exchange server. So, what happened? I figure I'll increase the file upload and timeout in the web.config file. Should I also increase the file upload in the web.config.comments file that affects the whole server? How do you edit the web.config.comments file? Just open it in Notepad, make the changes and save?
i have this forum page on my website. I want when users leave comment, the old comments should be at the bottom and new comments at the top. The code for that is below:
I am working on a project. I need to allow user to comment on pictures - like a blog. For example, if you like a picture, you post your comment on the pictures and say why you like. When the user type a comment in the text box, how do I put it under the pictures? Also, if two people were to post comments, how do I know where the first comment ends and where to start posting the second comments? Also, how do I know when the page is full and start a new page?
I have a details page, which lists the selected Restaurant. I want to be able to add comments at the bottom and display them. I have managed to add comments but only on a different page, i am struggling to get both the datails and the Comment create on the same form. This is what i have:
I'm trying to get the comments section for a user, to populate a text box which can be updated. I'm getting the "Object reference not set to an instance of an object" error. Why is this occurring?
I have a blog page that has 20 posts each page.I'm using Listview for displaying posts. If I want to display comments for each posts, what would be the best way? My database stracture is as follow
Since I have many comments for each posts, I don't think I can join table.Only thing I can think of is that I can use DataReader and loop through the results in Listview Databound events.What would be the best way to achieve this?