如何在 Laravel 中显示渲染时间/页面加载时间?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29250377/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 11:12:49  来源:igfitidea点击:

How to show render time / page load time in Laravel?

phplaravel

提问by Miftah Afina

I'm using Laravel and want to display render time / page load time in my web application. Can you help me?

我正在使用 Laravel 并希望在我的 Web 应用程序中显示渲染时间/页面加载时间。你能帮助我吗?

回答by Wader

Laravel defines a LARAVEL_STARTconstant which contains the microtime of when the framework started booting. You could use that to calculate the difference.

Laravel 定义了一个LARAVEL_START常量,其中包含框架开始启动的微时间。你可以用它来计算差异。

You can use the following

您可以使用以下

This page took {{ (microtime(true) - LARAVEL_START) }} seconds to render

回答by Maksym Cierzniak

I would recommend barryvdh/laravel-debugbarpackage which can give you plenty of informations about request including executed queries, various load times and many more.

我会推荐barryvdh/laravel-debugbar包,它可以为您提供大量有关请求的信息,包括执行的查询、各种加载时间等等。

回答by lieroes

You can use for debugging one of those package: barryvdh/laravel-debugbaror sebklaus/profiler

您可以用于调试这些包之一:barryvdh/laravel-debugbarsebklaus/profiler