脚本执行多久才算太长?
您认为 Web 脚本(例如 PHP)在开始成为用户烦恼之前可接受的最长时间执行(平均)是多少?我一直认为,如果用户必须等待超过 1 秒才能加载页面(当然这是在图像和 css 被缓存之后......这个规则实际上只适用于后续请求)他们会开始生气。
What is the max time do you think is acceptable for a web script (PHP for example) to execute before it starts to become an annoyance for the user (on average)? I always thought that if the user has to wait more than 1 second for the page to load (this of course after images and css have been cached..this rule really only applies for subsequent requests) they would start to get annoyed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
42秒。
事实上,事实是,这更多地取决于您所迎合的用户的年龄和期望。例如,我的父母可能更能容忍长时间的等待,但也更有可能一次又一次地按下按钮,就像他们按下人行横道或电梯按钮一样。
也就是说,真正的答案是,用户没有反馈多久才算太久?即使是快速启动沙漏徽标或进度条,也可以为用户带来巨大的变化。也就是说,如果您提供的服务应该是实时的并且像桌面应用程序一样运行,那么太长的时间基本上就是“任何可感知的”。
所以,逃避的答案......这取决于。也就是说,即使是“太长”的等待,也可以通过适当的 UI 设计和客户交互来克服。
42 seconds.
Actually, truth is it more comes down to the age and expectations of the user you are catering to. My parents for example, might be much more tolerant of an extended wait, but are also much more likely to press the button again and again, like they will to a crosswalk or elevator button.
That said the real answer is, how long is too long for the user to go without feedback? Even kicking up a quick hourglass logo, or progress bar, can make all the difference in the world for a user. That said, if the service you are providing should be realtime and act like a desktop app, too long is basically "anything perceptible".
So, cop-out answer... it depends. That said, even a "too long" wait, can be overcome by proper UI design and customer interaction.
雅各布·尼尔森 引用了一些对此的研究:
为了获得灵感,您可以查看 NetBeans 社区如何解释这些值:
Jacob Nielsen cites some research on this:
To serve as inspiration, you could look at how the NetBeans community interpret these values:
PHP 脚本执行的默认限制是 30 秒。如果您只是从用户的角度询问,那么经验法则是越快越好......
Well default limit for a PHP script execution is 30 seconds. If you are just asking from the users perspective then the rule of thumb would be the faster the better...
任何需要超过几秒处理时间的事情都应该以不同的方式处理,这里有一些示例
system()
使用 PHP 生成一个虚假进程Anything that takes more than a few seconds of process time should be handled differently, here are some examples
system()
看一下这个链接:
http://www.simple-talk.com/dotnet/.net-tools/the-cost-of-poor-website-performance/
,然后决定用户可以达到的挫败程度。
Take a look at this link:
http://www.simple-talk.com/dotnet/.net-tools/the-cost-of-poor-website-performance/
then just decide the level of frustration your users can reach.
我的经验法则:
在一般情况下将服务器端处理时间控制在 1 秒以内,在最坏的情况下绝对控制在 30 秒以内。
My rule of thumb:
Keep server-side processing under a second in the average case scenario and definitely under 30s in the worst case.
我想说的是,在您应该调用 (PHP)
ob_flush()
并至少向客户端发送一些内容之前几秒钟。否则电梯效应将接管并且用户将重复刷新。至于总页面加载量,只要您向用户发布信息就没关系。进度条将对此有所帮助。I'd say a couple of seconds before you should call (PHP)
ob_flush()
and at least send SOMETHING to the client. Otherwise the elevator effect will take over and the user will refresh repeatedly. As for total page load, it doesn't matter as long as you keep the user posted. A progress bar will help with that.久经考验的正确策略始终是管理期望。不要让用户再次猜测您或您的应用程序。如果根据您的基准测试,特定页面的平均处理时间将超出(例如 6 秒)阈值,请在用户单击按钮之前说明。这很像等待网站向您发送确认电子邮件,但不知道它何时到达,因为从未提及由于流量超出网站的控制而可能需要几个小时。
The tried and true strategy is always to manage expectations. Don't make a user second guess you or your application. If, by your benchmarks, the average processing time for a particular page will go beyond, say a 6-second threshold, say so before the user clicks a button. It's much like waiting for a Web site to send you a confirmation e-mail, not knowing when it will arrive, because it was never mentioned that it could take several hours due to traffic beyond the control of the site.
根据我的经验,如果某些事情需要花费超过几秒钟的时间,您至少应该给用户一些通知。可能会使用 AJAX 和一些精美的动画,并注意到“这需要一段时间”。
例如,如果您无法使用 AJAX,并且您的 PHP 脚本加载时间超过 10 秒,请尝试考虑一种优化方法。
From my experience, you should give the user at least some notice if something's gonna take more than few seconds. Possibly use AJAX with some fancy animation and notice like "This is gonna take a while".
If you cannot use AJAX and your PHP script is taking, for example, more than 10 seconds to load, try to think about a way to optimize it.