如何正确衡量 ColdFusion 执行时间?
1) ColdFusion Administrator 中的哪些设置应关闭/打开?
2) 您应该使用什么 ColdFusion 代码来正确基准执行时间(如 getTickCount())?
3) 您还应该提供哪些系统信息,例如 CF 引擎、版本、标准/企业、数据库等?
1) What settings in the ColdFusion Administrator should be turned off/on?
2) What ColdFusion code should you use to properly benchmark execution time like getTickCount()?
3) What system information should you provide also like CF Engine, Version, Standard/Enterprise, DB, etc?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我们要做的是:
onRequestStart()
->设置刻度计数值,添加到REQUEST
范围。onRequestEnd()
->设置刻度计数值,从中减去第一个值以获得以毫秒为单位的总处理时间随着时间的推移,这可以提供有关特定页面执行情况的非常有用的信息。这也可以很容易地绘制出来,这样您就可以看到一个页面是否突然开始花费 5000 毫秒,而之前需要 300 毫秒,然后您可以检查 SVN 以查看发生了什么变化:)
希望有所帮助!
What we do is:
onRequestStart()
-> set tick count value, add toREQUEST
scope.onRequestEnd()
-> set tick count value, subtract first value from it to get total processing time in msThis can give very useful information over time on how particular pages are performing. This can also be easily graphed so you can see if a page suddenly started taking 5000ms where before it was taking 300ms, and then you can check SVN to see what change did it :)
Hope that helps!
1)在CF管理员中,在调试设置中,您可以打开启用请求调试输出,该输出在每个页面的底部输出运行时和其他调试信息。如果您也想查看查询,这可能很有用。如果您想使用计时器,则必须在调试设置中选择计时器信息(对此很感兴趣)。
2) 您可以使用计时器来自定义执行时间基准。有四种类型:内联、外部、注释或调试,每种类型对应于输出的位置。在内联中,它将在您的代码周围创建一个小框(如果它是 .cfm)并打印总运行时间。其他的将打印在您在 CF 管理中打开的底部输出中。
3)我真的不知道你应该提供什么。希望我能提供更多帮助。在我看来,信息越多越好,所以我会说:P
1) In CF administrator, in Debug Settings, you can turn on Enable Request Debugging Output, which outputs runtime and other debugging information at the bottom of every page. This can be useful if you want to see queries as well. If you want to use timers to you must select Timer Information in the Debug Settings(got hung on that for a hot minute).
2) You can use timers to have custom benchmarks of execution times. There are four types, inline, outside,comment or debug, each corresponding to where the output will be. In inline, it will create a little box around your code(if its a .cfm) and print the total runtime. The others will print in the bottom output that you turned on in CF admin.
3) I don't really know what you should provide. Wish I could help more. In my opinion the more information the better, so that what I would say :P
关于@mbseid 的回答,请求调试会增加任何请求的大量处理时间,尤其是在使用 CFC 时。我建议您关闭请求调试并在页面顶部和底部使用 getTickCount() ,然后获取差异以获得渲染该页面的时间。这将使您更仔细地了解代码在生产中的执行情况。
with respect to @mbseid's answer, request debugging adds a significant amount of processing time to any request, especially if you use CFCs. I would recommend you turn request debugging off and use getTickCount() at the top and bottom of the page and then take the difference to get the time to render that page. This will give you a much closer reflection of how the code will perform in production.