Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
35b5b2ef
Commit
35b5b2ef
authored
Dec 31, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed profiling panel sorting.
parent
2df7d0a8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
14 deletions
+26
-14
Profile.php
extensions/yii/debug/models/search/Profile.php
+2
-2
ProfilingPanel.php
extensions/yii/debug/panels/ProfilingPanel.php
+12
-12
detail.php
extensions/yii/debug/views/default/panels/profile/detail.php
+12
-0
No files found.
extensions/yii/debug/models/search/Profile.php
View file @
35b5b2ef
...
@@ -53,9 +53,9 @@ class Profile extends Base
...
@@ -53,9 +53,9 @@ class Profile extends Base
'pageSize'
=>
10
,
'pageSize'
=>
10
,
],
],
'sort'
=>
[
'sort'
=>
[
'attributes'
=>
[
'category'
,
'
info'
,
'duration
'
],
'attributes'
=>
[
'category'
,
'
seq'
,
'duration'
,
'info
'
],
'defaultOrder'
=>
[
'defaultOrder'
=>
[
'
duration'
=>
SORT_DE
SC
,
'
seq'
=>
SORT_A
SC
,
],
],
],
],
]);
]);
...
...
extensions/yii/debug/panels/ProfilingPanel.php
View file @
35b5b2ef
...
@@ -61,7 +61,7 @@ class ProfilingPanel extends Panel
...
@@ -61,7 +61,7 @@ class ProfilingPanel extends Panel
/**
/**
* Calculates given request profile messages timings.
* Calculates given request profile messages timings.
* @return array timings
* @return array timings
[token, category, timestamp, traces, nesting level, elapsed time]
*/
*/
protected
function
calculateTimings
()
protected
function
calculateTimings
()
{
{
...
@@ -75,21 +75,19 @@ class ProfilingPanel extends Panel
...
@@ -75,21 +75,19 @@ class ProfilingPanel extends Panel
foreach
(
$messages
as
$i
=>
$log
)
{
foreach
(
$messages
as
$i
=>
$log
)
{
list
(
$token
,
$level
,
$category
,
$timestamp
,
$traces
)
=
$log
;
list
(
$token
,
$level
,
$category
,
$timestamp
,
$traces
)
=
$log
;
$log
[
5
]
=
$i
;
if
(
$level
==
Logger
::
LEVEL_PROFILE_BEGIN
)
{
if
(
$level
==
Logger
::
LEVEL_PROFILE_BEGIN
)
{
$stack
[]
=
$log
;
$stack
[]
=
$log
;
}
elseif
(
$level
==
Logger
::
LEVEL_PROFILE_END
)
{
}
elseif
(
$level
==
Logger
::
LEVEL_PROFILE_END
)
{
if
((
$last
=
array_pop
(
$stack
))
!==
null
&&
$last
[
0
]
===
$token
)
{
if
((
$last
=
array_pop
(
$stack
))
!==
null
&&
$last
[
0
]
===
$token
)
{
$timings
[
]
=
[
count
(
$stack
),
$token
,
$category
,
$timestamp
-
$last
[
3
],
$traces
];
$timings
[
$last
[
5
]]
=
[
$last
[
0
],
$last
[
2
],
$last
[
3
],
$last
[
4
],
count
(
$stack
),
$timestamp
-
$last
[
3
]
];
}
}
}
}
}
}
$now
=
microtime
(
true
);
ksort
(
$timings
);
while
((
$last
=
array_pop
(
$stack
))
!==
null
)
{
$timings
[]
=
[
count
(
$stack
),
$last
[
0
],
$last
[
2
],
$now
-
$last
[
3
],
$last
[
4
]];
}
return
$this
->
_timings
=
$timings
;
return
$this
->
_timings
=
array_values
(
$timings
)
;
}
}
public
function
save
()
public
function
save
()
...
@@ -113,12 +111,14 @@ class ProfilingPanel extends Panel
...
@@ -113,12 +111,14 @@ class ProfilingPanel extends Panel
$this
->
_models
=
[];
$this
->
_models
=
[];
$timings
=
$this
->
calculateTimings
();
$timings
=
$this
->
calculateTimings
();
foreach
(
$timings
as
$profileTiming
)
{
foreach
(
$timings
as
$
seq
=>
$
profileTiming
)
{
$this
->
_models
[]
=
[
$this
->
_models
[]
=
[
'duration'
=>
$profileTiming
[
3
]
*
1000
,
#in milliseconds
'duration'
=>
$profileTiming
[
5
]
*
1000
,
// in milliseconds
'category'
=>
$profileTiming
[
2
],
'category'
=>
$profileTiming
[
1
],
'info'
=>
$profileTiming
[
1
],
'info'
=>
$profileTiming
[
0
],
'level'
=>
$profileTiming
[
0
],
'level'
=>
$profileTiming
[
4
],
'timestamp'
=>
$profileTiming
[
2
],
'seq'
=>
$seq
,
];
];
}
}
}
}
...
...
extensions/yii/debug/views/default/panels/profile/detail.php
View file @
35b5b2ef
...
@@ -13,10 +13,22 @@ echo GridView::widget([
...
@@ -13,10 +13,22 @@ echo GridView::widget([
'columns'
=>
[
'columns'
=>
[
[
'class'
=>
'yii\grid\SerialColumn'
],
[
'class'
=>
'yii\grid\SerialColumn'
],
[
[
'attribute'
=>
'seq'
,
'label'
=>
'Time'
,
'value'
=>
function
(
$data
)
{
$timeInSeconds
=
$data
[
'timestamp'
]
/
1000
;
$millisecondsDiff
=
(
int
)((
$timeInSeconds
-
(
int
)
$timeInSeconds
)
*
1000
);
return
date
(
'H:i:s.'
,
$timeInSeconds
)
.
sprintf
(
'%03d'
,
$millisecondsDiff
);
},
],
[
'attribute'
=>
'duration'
,
'attribute'
=>
'duration'
,
'value'
=>
function
(
$data
)
{
'value'
=>
function
(
$data
)
{
return
sprintf
(
'%.1f ms'
,
$data
[
'duration'
]);
return
sprintf
(
'%.1f ms'
,
$data
[
'duration'
]);
},
},
'options'
=>
[
'width'
=>
'10%'
,
],
],
],
'category'
,
'category'
,
[
[
...
...
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