Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
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
outils
question2answer
Commits
4564860c
Commit
4564860c
authored
May 02, 2015
by
Scott
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'pr/215' into dev
parents
a0d486a1
54d107b3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
36 deletions
+67
-36
Usage.php
qa-include/Q2A/Util/Usage.php
+67
-36
No files found.
qa-include/Q2A/Util/Usage.php
View file @
4564860c
...
...
@@ -104,25 +104,80 @@ class Q2A_Util_Usage
$totaldelta
=
$this
->
delta
(
$this
->
startUsage
,
$this
->
getCurrent
());
?>
<style>
.debug-table
{
border-collapse
:
collapse
;
box-sizing
:
border-box
;
width
:
100%
;
margin
:
20px
auto
;
}
.debug-table
tr
{
background-color
:
#ccc
;
}
.debug-table
td
{
padding
:
10px
;
}
.debug-table
{
border-collapse
:
collapse
;
width
:
auto
;
margin
:
20px
auto
;
}
.debug-table
th
,
.debug-table
td
{
border
:
1px
solid
#aaa
;
background-color
:
#ddd
;
padding
:
5px
10px
;
}
.debug-table
td
{
text-align
:
right
;
}
.debug-table
th
:empty
{
border
:
none
;
background-color
:
initial
;
}
.debug-table
.row-heading
{
font-weight
:
bold
;
}
td
.debug-cell-files
{
width
:
30%
;
padding-right
:
5px
;
}
td
.debug-cell-queries
{
width
:
70%
;
padding-left
:
5px
;
}
.debug-table
tr
:last-child
td
{
background-color
:
#ccc
;
border-top-width
:
3px
;
}
textarea
.debug-output
{
box-sizing
:
border-box
;
width
:
100%
;
font
:
12px
monospace
;
color
:
#000
;
}
.extra-info
{
border-collapse
:
collapse
;
box-sizing
:
border-box
;
width
:
100%
;
}
.extra-info
td
.debug-cell-files
{
width
:
30%
;
padding
:
10px
5px
10px
10px
;
}
.extra-info
td
.debug-cell-queries
{
width
:
70%
;
padding
:
10px
10px
10px
5px
;
}
.extra-info
tr
{
background-color
:
#ccc
;
}
.extra-info
textarea
{
margin
:
0
;
}
</style>
<table
class=
"debug-table"
>
<thead>
<tr>
<th></th>
<th
colspan=
"2"
>
Total
</th>
<th
colspan=
"3"
>
PHP
</th>
<th
colspan=
"3"
>
MySQL
</th>
<th
colspan=
"2"
>
Other
</th>
<th
colspan=
"2"
>
RAM
</th>
</tr>
<tr>
<th></th>
<th>
Time (ms)
</th>
<th>
%
</th>
<th>
Time (ms)
</th>
<th>
%
</th>
<th>
File count
</th>
<th>
Time (ms)
</th>
<th>
%
</th>
<th>
Query count
</th>
<th>
Time (ms)
</th>
<th>
%
</th>
<th>
Amount
</th>
<th>
%
</th>
</tr>
</thead>
<tbody>
<?php
$stages
=
$this
->
stages
;
$stages
[
'total'
]
=
$totaldelta
;
foreach
(
$stages
as
$stage
=>
$stagedelta
)
:
?>
<tr>
<td
class=
"row-heading"
>
<?php
echo
ucfirst
(
$stage
);
?>
</td>
<td>
<?php
echo
sprintf
(
'%.1f'
,
$stagedelta
[
'clock'
]
*
1000
);
?>
</td>
<td>
<?php
echo
sprintf
(
'%d%%'
,
$stagedelta
[
'clock'
]
*
100
/
$totaldelta
[
'clock'
]);
?>
</td>
<td>
<?php
echo
sprintf
(
'%.1f'
,
$stagedelta
[
'cpu'
]
*
1000
);
?>
</td>
<td>
<?php
echo
sprintf
(
'%d%%'
,
$stagedelta
[
'cpu'
]
*
100
/
$totaldelta
[
'clock'
]);
?>
</td>
<td>
<?php
echo
$stagedelta
[
'files'
];
?>
</td>
<td>
<?php
echo
sprintf
(
'%.1f'
,
$stagedelta
[
'mysql'
]
*
1000
);
?>
</td>
<td>
<?php
echo
sprintf
(
'%d%%'
,
$stagedelta
[
'mysql'
]
*
100
/
$totaldelta
[
'clock'
]);
?>
</td>
<td>
<?php
echo
$stagedelta
[
'queries'
];
?>
</td>
<td>
<?php
echo
sprintf
(
'%.1f'
,
$stagedelta
[
'other'
]
*
1000
);
?>
</td>
<td>
<?php
echo
sprintf
(
'%d%%'
,
$stagedelta
[
'other'
]
*
100
/
$totaldelta
[
'clock'
]);
?>
</td>
<td>
<?php
echo
sprintf
(
'%dk'
,
$stagedelta
[
'ram'
]
/
1024
);
?>
</td>
<td>
<?php
echo
sprintf
(
'%d%%'
,
$stagedelta
[
'ram'
]
?
(
$stagedelta
[
'ram'
]
*
100
/
$totaldelta
[
'ram'
])
:
0
);
?>
</td>
</tr>
<?php
endforeach
;
?>
</tbody>
</table>
<table
class=
"extra-info"
>
<tbody>
<tr>
<td
colspan=
"2"
>
<?php
echo
$this
->
line
(
'Total'
,
$totaldelta
,
$totaldelta
)
.
"<br>
\n
"
;
foreach
(
$this
->
stages
as
$stage
=>
$stagedelta
)
echo
'<br>'
.
$this
->
line
(
ucfirst
(
$stage
),
$stagedelta
,
$totaldelta
)
.
"
\n
"
;
?>
</td>
</tr>
<tr>
<td
class=
"debug-cell-files"
>
<textarea
class=
"debug-output"
cols=
"40"
rows=
"20"
>
<?php
...
...
@@ -153,28 +208,4 @@ class Q2A_Util_Usage
return
$delta
;
}
/**
* Return HTML to represent the resource $usage, showing appropriate proportions of $totalusage.
*/
private
function
line
(
$stage
,
$usage
,
$totalusage
)
{
return
sprintf
(
"%s – <b>%.1fms</b> (%d%%) – PHP %.1fms (%d%%), MySQL %.1fms (%d%%), Other %.1fms (%d%%) – %d PHP %s, %d DB %s, %dk RAM (%d%%)"
,
$stage
,
$usage
[
'clock'
]
*
1000
,
$usage
[
'clock'
]
*
100
/
$totalusage
[
'clock'
],
$usage
[
'cpu'
]
*
1000
,
$usage
[
'cpu'
]
*
100
/
$totalusage
[
'clock'
],
$usage
[
'mysql'
]
*
1000
,
$usage
[
'mysql'
]
*
100
/
$totalusage
[
'clock'
],
$usage
[
'other'
]
*
1000
,
$usage
[
'other'
]
*
100
/
$totalusage
[
'clock'
],
$usage
[
'files'
],
$usage
[
'files'
]
==
1
?
'file'
:
'files'
,
$usage
[
'queries'
],
$usage
[
'queries'
]
==
1
?
'query'
:
'queries'
,
$usage
[
'ram'
]
/
1024
,
$usage
[
'ram'
]
?
(
$usage
[
'ram'
]
*
100
/
$totalusage
[
'ram'
])
:
0
);
}
}
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