VB.NET gets the page execution time

xiaoxiao2021-03-06  59

In the past, I saw the program for calculating the page execution time in the Internet, most of which is implemented using C #, and the method type is basically similar. And most of them are recorded start and end time, and finally define a TimeSpan to calculate the time difference, but when writing the code, it is endtime - startTime, I have no test, but in VB.NET, because of the time variable You cannot use "-" to calculate. I use the additional functions, as follows: add the following code Global file: Public StartTime As System.DateTime Public EndTime As System.DateTime Public ts As System.TimeSpan Sub Application_BeginRequest (ByVal sender As Object, ByVal e As EventArgs) ' StartTime excitation at the start of each request = System.DateTime.Now end SubSub Application_EndRequest (ByVal sender As Object, ByVal e As EventArgs) 'excitation EndTime = System.DateTime.Now ts = EndTime.Subtract (StartTime at the end of each request ) Response.write ("

Page Request Time:" & Ts.totalmilliseconds.toString () & "MilliseCond ) End Sub

转载请注明原文地址:https://www.9cbs.com/read-113663.html

New Post(0)