php - php max_execution_time 实际测量的是什么?
问题描述
我有一个网页,上面有一个按钮,单击该按钮时会执行一个 php 函数。
当用户点击它时,返回一个页面需要51081ms。其中 51376 毫秒被我的 Firefox 开发人员工具中的“网络”选项卡归类为“等待”。
在我的 php.ini 文件中声明的 max_execution_time 是 30。我也可以在我的 phpinfo 文件中看到这一点。
我的问题是,为什么我的脚本在 30 秒后没有超时?max_execution_time 实际测量的是什么?
编辑以包含代码;
public function getSlotsByUser (Request $request) {
$event_id = $request->event_id;
$user_id = substr($request->user, 4);
$event = Event::find($event_id);
$user = User::find($user_id);
$slots = TimeSlot::where('event_id',$event_id)->get();
$userSlots = $user->slots;
foreach($userSlots as $userSlot) {
$guest = Guest::where('slot_id',$userSlot->id)->where('user_id',$user->id)->first();
if($guest) {
$userSlot->guest_id = $guest->id;
$userSlot->guest_name = $guest->name . ' ' . $guest->surname;
}
else {
$userSlot->guest_id = NULL;
$userSlot->guest_name = NULL;
}
$userSlotIds[] = $userSlot->id;
}
$days = new DatePeriod(
new DateTime($event->start_time),
new DateInterval('P1D'),
(new DateTime($event->end_time))->modify('+1 day')
);
return view('admin.calendar',compact('event','slots','user','userSlots','userSlotIds','days'));
}
我了解哪些部分代表使用 Eloquent 的查询。我的代码也是如此;
php执行
php执行
数据库查询
数据库查询
数据库查询
php执行...等等?
有人可以向我解释“引擎盖下”发生了什么吗?
解决方案
max_execution_time 只影响脚本本身的执行时间。在确定脚本运行的最长时间时,不包括在脚本执行之外发生的活动所花费的任何时间,例如使用 system() 的系统调用、流操作、数据库查询等。这在测量时间是真实的 Windows 上是不正确的。
所以在 Linux 上只计算用于执行 php 代码的时间。
网络选项卡waiting
中的 只是告诉您直到现在您还没有从网络服务器得到任何响应。
推荐阅读
- android - 如何在 react-native 应用程序中询问多个权限?
- recursion - 使用主定理求解 4T(n/2) + n^2(logn)^3
- firefox - Firefox CanvasBlocker 不显示 reCaptcha 图像
- angular - 如何以角度加密 API 输入和输出?
- r - 对另一列中的条件进行抽样
- docker - 使用一键部署方法(Kubernetes)安装 Acumos 时面临的问题
- airflow - 如何使用 Celery 配置 Apache Airflow 以运行并发任务?
- android - 重新启用滚动后,水平 RecyclerView 不会向左滚动
- django - 如何从 Django 中的表单安全地更新模型
- javascript - 在同一 HTML 中的 PHP 和 JS 之间传递变量