Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C# (Urgent): messure how long a script needs

Posted on 2003-11-19
3
Medium Priority
?
275 Views
Last Modified: 2010-04-17
I need to know how long the execution of a script with DB connections take.

In VB it was done like this:
<html>
<%
startTime = Timer
......
// some DB connections etc...
......
%>
<%= Timer - StartTime %>
</html>


How do you do this best/most effective in C# ?
thank you
0
Comment
Question by:Smoerble
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Expert Comment

by:TRUENEUTRAL
ID: 9780482
That looks like ASP code (VBScript).  C# is compiled code.  You will need to use ASP.NET (in which case you can still use the VBScript you listed above)

Perhaps you should elaborate?
0
 

Author Comment

by:Smoerble
ID: 9780519
THanks for your comment, but I know that C# is compiled code, the question is how would you do this in C#?
E.g. I could get the startTime in the PageLoad-Event, but what are the exact classes/methods I need and how woudl you calculate the result?

thank you
0
 
LVL 5

Accepted Solution

by:
TRUENEUTRAL earned 1000 total points
ID: 9781913
Here's how you can get it with vb code... not sure how to get ASP.NET to use C# code, though.

Public Class WebForm1
    Inherits System.Web.UI.Page
    Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox

    Public load_time As Double

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
        load_time = Now().ToOADate

    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
    End Sub

    Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
        writer.Write(load_time.ToString)
        writer.Write("<br>")
        writer.Write(Now().ToOADate.ToString)



    End Sub
End Class
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Starting up a Project

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question