PHP 页面生成时间应该是多长

发布于 2024-08-21 12:27:31 字数 359 浏览 5 评论 0原文

我在网上搜索此内容但没有找到令人满意的答案。

我不是在谈论浏览器渲染和显示所需的时间。 仅在服务器本身中生成 HTML 的部分。

<?php
$script_start = microtime_float();
#CODE
echo (microtime_float()-$script_start)
?>

网页中接受/正常的时间是多少。 假设该页面有日历、民意调查、内容、菜单(带有子菜单)和一些其他模块。

如果小于 0.05 秒可以吗?

您认为应该花费的最高正常/接受时间是多少?

I was searching the web for this but found no satisfying answer.

I am not talking about the time it takes the browser to render and display.
Only the part where the HTML is generated in the server itself.

<?php
$script_start = microtime_float();
#CODE
echo (microtime_float()-$script_start)
?>

What is the accepted/normal time in web pages.
Lets say the page has a calendar, poll, content, menus(with submenus), some other modules.

Is it okay if it is less than 0.05seconds?

What do you think, what is the highest normal/accepted time it should take?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

蹲墙角沉默 2024-08-28 12:27:31

我有一根绳子,请问它有多长?

您的页面将花费所需的时间,具体取决于您想要执行的操作、尝试执行的方式、运行的平台、是否正在整理来自第三方和第三方的数据。一千多个其他不可知的变量。

用户认为可接受的内容会有一个上限,如果您发现自己经常违反该界限,那么您可以尝试一些解决方法,例如缓存数据、lowsrc、异步元素等。

但就目前情况而言,没有具体的答案对于这个一般性问题。

I've got this bit of string, how long should it be?

Your page will take as long as it needs to, based on what you're trying to do, how you're trying to do it, what platform you're running on, whether you're marshalling data from third-parties and a thousand and one other unknowable variables.

There will be an upper limit on what your users find acceptable, and if you find yourself frequently breaching that bound, then you could try some workarounds, e.g. caching data, lowsrc, asynchronous elements, etc.

But as it stands, there's no specific answer to this general question.

一紙繁鸢 2024-08-28 12:27:31

您应该阅读这个故事关于 Google 对这个主题的测量。

You should read this story about Google's measurements on this very topic.

夏夜暖风 2024-08-28 12:27:31

我认为不存在所谓的“最高可接受时间”之类的东西。正如@Johannes 指出的,这取决于您拥有多少用户。执行速度对于 Facebook 来说很重要 - 他们甚至为它编写了一个编译器:) http://www. phpbench.com/ 以及 http:// /phplens.com/lens/php-book/optimizing-debugging-php.php

I think there is no such thing like as a highest accepted time. As @Johannes points out it depends on how many users you have. Execution speed matters for Facebook - they even wrote a Compiler for it :) There are some nice benchmarks on http://www.phpbench.com/ and some optimizing tips on http://phplens.com/lens/php-book/optimizing-debugging-php.php

甜妞爱困 2024-08-28 12:27:31

这个问题没有正确的答案,无论是令人满意的还是其他的。显然,您的目标应该是在尽可能短的时间内渲染 html,但您不能任意确定应该多长时间。

话虽如此,如果您的页面渲染时间少于 0.05 秒,我认为您没有什么可担心的!

There's no correct answer to this, satisfying or otherwise. You should obviously be aiming to render the html in as little time as possible, but you can't put an arbitrary figure on how long that should be.

Having said that, if your pages are rendering in less than 0.05 seconds I don't think you've got anything to worry about!

无所的.畏惧 2024-08-28 12:27:31

这就是所谓的“非功能性需求”之一。他们常常被遗忘。其他问题是“我的页面应该多久崩溃一次”、“所需的正常运行时间是多少”、“打印时页面看起来应该有所不同吗?”...

您应该看看您的 php 应该如何使用:它会是从其他网页调用的,还是一个独立的应用程序?如果 html 生成成为延迟的主要部分,用户是否会感到困扰?...

That's one of the so-called "non-functional requirements". Too often they're forgotten. Others are "how often should my page crash", and "what's the desired uptime", and "should the page look different when printed?"...

You should take a look at how your php should be used: is it going to be called from other web-pages, or is it a stand-alone app? Is the user going to be bothered if the html-generation becomes the bigger part of the latency?...

于我来说 2024-08-28 12:27:31

观察以下内容通常会更高效:

  • 数据库查询需要多长时间
  • 从异地请求获取数据需要多长时间

……这些单独加起来就是单页面加载时间。如果无法缩小瓶颈范围,那么测量页面加载所需的时间就没有意义。

超过一两秒,有人可能会开始摆弄后退或刷新按钮,或者只是关闭浏览器选项卡。再说一遍,这是主观的,并且基于我对“典型的人”期望事情如何运作的想法。

Its usually more productive to observe the following:

  • How long database queries take
  • How long it takes to get data from off site requests

... which individually add up to the single page load time. There's no sense in measuring how long a page takes to load if you can't narrow down the bottlenecks.

More than a second or two, someone is likely going to start fiddling with their back or refresh buttons, or just close the browser tab. Again, that's subjective and based on my idea of how a 'typical someone' expects things to work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文