Solved

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

Posted on 2003-11-19
3
238 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
  • 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 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now