如何获取 PHP 的初始化或启动时间
我想知道在运行/执行 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为解释器的启动时间根本不是用于此比较的有用指标。
例如,您可以做的是使用两种不同的脚本语言设置两个 Web 服务器,向执行某些标准任务的脚本发出 Web 请求,并测量第一个字节到达之前的时间。这可能会让您对每个平台的性能有一个比较真实的了解。
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.
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 by100
(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.