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
ba3a6033
Commit
ba3a6033
authored
Apr 04, 2013
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move apdex column related code to top level for easier reuse.
parent
9aa3b814
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
17 deletions
+27
-17
apachedex/__init__.py
apachedex/__init__.py
+27
-17
No files found.
apachedex/__init__.py
View file @
ba3a6033
...
@@ -74,6 +74,30 @@ def getClassForStatusHit(hit, status):
...
@@ -74,6 +74,30 @@ def getClassForStatusHit(hit, status):
return
'problem'
return
'problem'
return
''
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
):
apdex
=
data
.
getApdex
()
average
=
data
.
getAverage
()
maximum
=
data
.
getMax
()
return
'<td style="%s">%i%%</td>'
\
'<td>%s</td><td class="%s">%.2f</td><td class="%s">%.2f</td>'
%
(
getApdexStyle
(
apdex
),
apdex
*
100
,
data
.
hit
,
getClassForDuration
(
average
,
threshold
),
average
,
getClassForDuration
(
maximum
,
threshold
),
maximum
,
)
APDEX_TABLE_HEADERS
=
''
.
join
(
'<th>'
+
x
+
'</th>'
for
x
in
(
'apdex'
,
'hits'
,
'avg (s)'
,
'max (s)'
))
class
APDEXStats
(
object
):
class
APDEXStats
(
object
):
def
__init__
(
self
,
threshold
):
def
__init__
(
self
,
threshold
):
threshold
*=
US_PER_S
threshold
*=
US_PER_S
...
@@ -295,29 +319,15 @@ class ERP5SiteStats(GenericSiteStats):
...
@@ -295,29 +319,15 @@ class ERP5SiteStats(GenericSiteStats):
append
(
'<th colspan="4">%s</th>'
%
date
)
append
(
'<th colspan="4">%s</th>'
%
date
)
append
(
'</tr><tr>'
)
append
(
'</tr><tr>'
)
for
_
in
xrange
(
len
(
column_list
)
+
1
):
for
_
in
xrange
(
len
(
column_list
)
+
1
):
append
(
'<th>Apdex</th><th>hits</th><th>avg (s)</th>'
append
(
APDEX_TABLE_HEADERS
)
'<th>max (s)</th>'
)
append
(
'</tr>'
)
append
(
'</tr>'
)
def
apdexStatsAsHtml
(
data
):
apdex
=
data
.
getApdex
()
return
'<td style="color: #%s; background-color: #%s">%i%%</td>'
\
'<td>%s</td><td class="%s">%.2f</td><td class="%s">%.2f</td>'
%
(
(
apdex
<
.
5
and
'f'
or
'0'
)
*
3
,
(
'%x'
%
(
apdex
*
0xf
))
*
3
,
apdex
*
100
,
data
.
hit
,
getClassForDuration
(
data
.
getAverage
(),
self
.
threshold
),
data
.
getAverage
(),
getClassForDuration
(
data
.
getMax
(),
self
.
threshold
),
data
.
getMax
(),
)
def
apdexAsColumns
(
data_dict
):
def
apdexAsColumns
(
data_dict
):
data_total
=
APDEXStats
(
self
.
threshold
)
data_total
=
APDEXStats
(
self
.
threshold
)
for
data
in
data_dict
.
values
():
for
data
in
data_dict
.
values
():
data_total
.
accumulateFrom
(
data
)
data_total
.
accumulateFrom
(
data
)
append
(
apdexStatsAsHtml
(
data_total
))
append
(
getApdexStatsAsHtml
(
data_total
,
self
.
threshold
))
for
date
in
column_list
:
for
date
in
column_list
:
append
(
apdexStatsAsHtml
(
data_dict
[
date
]
))
append
(
getApdexStatsAsHtml
(
data_dict
[
date
],
self
.
threshold
))
for
module_id
,
data_dict
in
sorted
(
filtered_module
.
iteritems
(),
for
module_id
,
data_dict
in
sorted
(
filtered_module
.
iteritems
(),
key
=
ITEMGETTER0
):
key
=
ITEMGETTER0
):
append
(
'<tr><th rowspan="2">%s</th><th>module</th>'
%
module_id
)
append
(
'<tr><th rowspan="2">%s</th><th>module</th>'
%
module_id
)
...
...
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