如何获取 PHP 的初始化或启动时间

发布于 2024-12-16 23:03:45 字数 105 浏览 0 评论 0原文

我想知道在运行/执行 PHP 文件之前哪些文件用于初始化或启动 PHP。

另外,我如何计算 PHP 的初始化或启动时间?(在本地和服务器上)

任何人都可以帮助我吗?

I want to know which files are used to initialize or start PHP before running/executing a PHP file.

Also, How can I calculate the initialization or startup time of PHP?(on local and server both)

Can anyone help me with it?

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

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

发布评论

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

评论(2

一口甜 2024-12-23 23:03:48

我想计算启动时间,以便我可以将其与另一种脚本语言进行比较,并在此基础上获得其性能的一些结果

我认为解释器的启动时间根本不是用于此比较的有用指标。

例如,您可以做的是使用两种不同的脚本语言设置两个 Web 服务器,向执行某些标准任务的脚本发出 Web 请求,并测量第一个字节到达之前的时间。这可能会让您对每个平台的性能有一个比较真实的了解。

I want to calculate the startup time so that I can compare it with another scripting language and based on that get some results of its performance

I don't think the interpreter's startup time is a useful metric for this comparison at all.

What you could do, for example, is set up two web servers with two different scripting languages, make a web request to a script that does some standard task, and measure the time until the first byte arrives. That might give you a somewhat realistic picture of each platform's performance.

清风疏影 2024-12-23 23:03:47

Linux内核在/proc//stat中提供了进程的启动时间;这是第22场。它计算程序启动之前自引导以来的 jiffies 数。我相信现在许多版本的“jiffies”已固定为 100/秒,尽管我无法说出具体是哪个版本引入了它。

将启动后的时间(以 jiffies 为单位)转换为有用时间有点困难,但这都是算术。

time(2) 返回自纪元以来的时间(以秒为单位);将进程的启动时间除以100(或您平台上的任何jiffies/秒)即可获得自启动以来的秒数,从另一个中减去一个即可获得自启动以来进程的启动时间(以秒为单位)纪元,并根据需要将其转换为您喜欢的格式。

The Linux kernel provides the start time of a process in /proc/<pid>/stat; it is the 22nd field. It counts the number of jiffies since boot before the program was started. I believe the "jiffies" has been fixed at 100 / second for many versions now, though I can't name which specific one introduced it.

It's a little difficult to convert the time in jiffies since boot into a useful time, but that's all arithmetic.

time(2) returns the time in seconds since the epoch; divide your process's start time by 100 (or whatever the jiffies / second is on your platform) to get seconds since boot, subtract the one from the other to get the start time of your process in seconds since the epoch, and convert that to your favorite formatting as you need.

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