ASP.net VB 定时器
我希望能够在 ASP.net (VBscript) 中计算页面加载时间。将 Trace="true" 添加到页面指令很好,但我需要实际计时事件并将其存储在变量中。
在 ASP 中,使用 Timer 对象很容易,但在 .net 中我在 Google 上找不到任何东西。
我需要一些类似的东西:
Dim startTime
Dim endTime
startTime = now()
doBigFunction()
endTime = now()
response.write("That took " & endTime - startTime & " milliseconds")
干杯!
I would like to be able to time a page load time in ASP.net (VBscript). Adding Trace="true" to the page directive is nice, but I need to actually time an event and store it in a variable.
In ASP it was easy with the Timer object, but in .net I can't find anything on Google.
I need something along the lines of:
Dim startTime
Dim endTime
startTime = now()
doBigFunction()
endTime = now()
response.write("That took " & endTime - startTime & " milliseconds")
Cheers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试使用秒表
您不必计算,如果调用 stopWatch.Reset() 则可以重用它
从这里获取示例: http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx
Try a StopWatch
You don't have to calculate and you can reuse it if you call stopWatch.Reset()
Took the example from here: http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx
DataTime 类中有一个 DateTime.Now 静态成员可以执行您希望它执行的操作:
There is a DateTime.Now static member of the DataTime class that does what you want it to do:
对于此级别,您可以使用
DateTime.Now< /code>
属性。
TimeSpan
是区别两个DateTime
值之间。为了获得更准确的结果,您需要
秒表
。For this level you can use the
DateTime.Now
property. ATimeSpan
is the difference between twoDateTime
values.For something more accurate you need the
Stopwatch
.