Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
php_frq_api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
bd540e5d
authored
Jul 21, 2021
by
duwenjun
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
性能分析
parent
44262997
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
app/Http/Kernel.php
app/Http/Middleware/TideWaysProf.php
app/Http/Kernel.php
View file @
bd540e5d
...
...
@@ -15,6 +15,7 @@ class Kernel extends HttpKernel
* @var array
*/
protected
$middleware
=
[
\App\Http\Middleware\TideWaysProf
::
class
,
// 接口性能分析中间件
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode
::
class
,
EnableCrossRequestMiddleware
::
class
,
];
...
...
app/Http/Middleware/TideWaysProf.php
0 → 100644
View file @
bd540e5d
<?php
namespace
App\Http\Middleware
;
use
Closure
;
class
TideWaysProf
{
public
function
handle
(
$request
,
Closure
$next
)
{
$tideways_enable
=
get_resource_config_section
(
'app'
,
'frq_api'
)[
'tideways_enable'
];
if
(
$tideways_enable
&&
function_exists
(
'tideways_xhprof_enable'
))
{
list
(
$usec
,
$sec
)
=
explode
(
" "
,
microtime
());
$startTime
=
(
float
)
$sec
+
(
float
)
$usec
;
// 程序开始时间
tideways_xhprof_enable
();
$response
=
$next
(
$request
);
if
(
function_exists
(
'tideways_xhprof_disable'
)){
list
(
$usec
,
$sec
)
=
explode
(
" "
,
microtime
());
$endTime
=
(
float
)
$sec
+
(
float
)
$usec
;
$data
=
tideways_xhprof_disable
();
if
((
$endTime
-
$startTime
)
>
0.5
)
{
file_put_contents
(
sys_get_temp_dir
()
.
uniqid
()
.
".frq_api"
.
str_replace
(
'/'
,
"-"
,
$request
->
path
())
.
'.xhprof'
,
serialize
(
$data
));
}
}
return
$response
;
}
else
{
return
$next
(
$request
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment