Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apachedex
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Arnaud Fontaine
apachedex
Commits
8cde1631
Commit
8cde1631
authored
Apr 07, 2013
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Objectify APDEXStats HTML rendering.
parent
d14743d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
52 deletions
+46
-52
apachedex/__init__.py
apachedex/__init__.py
+46
-52
No files found.
apachedex/__init__.py
View file @
8cde1631
...
...
@@ -83,51 +83,6 @@ def getClassForStatusHit(hit, status):
return
'problem'
return
''
def
getApdexStyle
(
apdex
):
return
'color: #%s; background-color: #%s'
%
(
(
apdex
<
.
5
and
'f'
or
'0'
)
*
3
,
(
'%x'
%
(
apdex
*
0xf
))
*
3
,
)
def
getApdexStatsAsHtml
(
data
,
threshold
,
overall
=
False
):
apdex
=
data
.
getApdex
()
average
=
data
.
getAverage
()
maximum
=
data
.
getMax
()
hit
=
data
.
hit
if
hit
:
extra_class
=
''
apdex_style
=
getApdexStyle
(
apdex
)
else
:
extra_class
=
'no_hit'
apdex_style
=
''
if
overall
:
extra_right_class
=
'overall_right'
else
:
extra_right_class
=
''
return
'<td style="%(apdex_style)s" class="%(extra_class)s group_left">'
\
'%(apdex)i%%</td><td class="%(extra_class)s">%(hit)s</td>'
\
'<td class="%(average_class)s %(extra_class)s">%(average).2f</td>'
\
'<td class="%(max_class)s %(extra_class)s group_right '
\
'%(extra_right_class)s">%(max).2f</td>'
%
{
'extra_class'
:
extra_class
,
'apdex_style'
:
apdex_style
,
'apdex'
:
apdex
*
100
,
'hit'
:
hit
,
'average_class'
:
getClassForDuration
(
average
,
threshold
),
'average'
:
average
,
'max_class'
:
getClassForDuration
(
maximum
,
threshold
),
'max'
:
maximum
,
'extra_right_class'
:
extra_right_class
,
}
def
getApdexTableHeader
(
overall
=
False
):
if
overall
:
extra
=
' class="overall_right"'
else
:
extra
=
''
return
'<th>apdex</th><th>hits</th><th>avg (s)</th>'
\
'<th%s>max (s)</th>'
%
extra
def
getDataPoints
(
apdex_dict
):
return
[
(
date
,
apdex
.
getApdex
()
*
100
,
apdex
.
hit
)
for
date
,
apdex
...
...
@@ -249,6 +204,45 @@ class APDEXStats(object):
def
getMax
(
self
):
return
float
(
self
.
duration_max
)
/
US_PER_S
@
staticmethod
def
asHTMLHeader
(
overall
=
False
):
return
'<th>apdex</th><th>hits</th><th>avg (s)</th>'
\
'<th%s>max (s)</th>'
%
(
overall
and
' class="overall_right"'
or
''
)
def
asHTML
(
self
,
threshold
,
overall
=
False
):
apdex
=
self
.
getApdex
()
average
=
self
.
getAverage
()
maximum
=
self
.
getMax
()
hit
=
self
.
hit
if
hit
:
extra_class
=
''
apdex_style
=
'color: #%s; background-color: #%s'
%
(
(
apdex
<
.
5
and
'f'
or
'0'
)
*
3
,
(
'%x'
%
(
apdex
*
0xf
))
*
3
,
)
else
:
extra_class
=
'no_hit'
apdex_style
=
''
if
overall
:
extra_right_class
=
'overall_right'
else
:
extra_right_class
=
''
return
'<td style="%(apdex_style)s" class="%(extra_class)s group_left">'
\
'%(apdex)i%%</td><td class="%(extra_class)s">%(hit)s</td>'
\
'<td class="%(average_class)s %(extra_class)s">%(average).2f</td>'
\
'<td class="%(max_class)s %(extra_class)s group_right '
\
'%(extra_right_class)s">%(max).2f</td>'
%
{
'extra_class'
:
extra_class
,
'apdex_style'
:
apdex_style
,
'apdex'
:
apdex
*
100
,
'hit'
:
hit
,
'average_class'
:
getClassForDuration
(
average
,
threshold
),
'average'
:
average
,
'max_class'
:
getClassForDuration
(
maximum
,
threshold
),
'max'
:
maximum
,
'extra_right_class'
:
extra_right_class
,
}
class
GenericSiteStats
(
object
):
def
__init__
(
self
,
threshold
,
getDuration
,
suffix
,
error_detail
=
False
):
self
.
threshold
=
threshold
...
...
@@ -298,16 +292,16 @@ class GenericSiteStats(object):
for
data
in
self
.
apdex
.
itervalues
():
apdex
.
accumulateFrom
(
data
)
append
(
'<h2>Overall</h2><table class="stats"><tr>'
)
append
(
getApdexTable
Header
())
append
(
APDEXStats
.
asHTML
Header
())
append
(
'</tr><tr>'
)
append
(
getApdexStatsAsHtml
(
apdex
,
self
.
threshold
))
append
(
apdex
.
asHTML
(
self
.
threshold
))
append
(
'</tr></table><h2>Hottest pages</h2><table class="stats"><tr>'
)
append
(
getApdexTable
Header
())
append
(
APDEXStats
.
asHTML
Header
())
append
(
'<th>url</th></tr>'
)
for
url
,
data
in
sorted
(
self
.
url_apdex
.
iteritems
(),
key
=
lambda
x
:
x
[
1
].
getAverage
()
*
x
[
1
].
hit
,
reverse
=
True
)[:
N_SLOWEST
]:
append
(
'<tr>'
)
append
(
getApdexStatsAsHtml
(
data
,
self
.
threshold
))
append
(
data
.
asHTML
(
self
.
threshold
))
append
(
'<td class="text">%s</td></tr>'
%
escape
(
url
))
append
(
'</table>'
)
column_set
=
set
()
...
...
@@ -457,15 +451,15 @@ class ERP5SiteStats(GenericSiteStats):
append
(
'<th colspan="4">%s</th>'
%
date
)
append
(
'</tr><tr>'
)
for
i
in
xrange
(
len
(
column_list
)
+
1
):
append
(
getApdexTable
Header
(
i
==
0
))
append
(
APDEXStats
.
asHTML
Header
(
i
==
0
))
append
(
'</tr>'
)
def
apdexAsColumns
(
data_dict
):
data_total
=
APDEXStats
(
self
.
threshold
,
None
)
for
data
in
data_dict
.
values
():
data_total
.
accumulateFrom
(
data
)
append
(
getApdexStatsAsHtml
(
data_total
,
self
.
threshold
,
True
))
append
(
data_total
.
asHTML
(
self
.
threshold
,
True
))
for
date
in
column_list
:
append
(
getApdexStatsAsHtml
(
data_dict
[
date
],
self
.
threshold
))
append
(
data_dict
[
date
].
asHTML
(
self
.
threshold
))
def
hiddenGraph
(
data_dict
,
title
):
append
(
'<td class="text group_right hidden_graph">'
)
data
=
getDataPoints
(
data_dict
)
...
...
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