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
Jérome Perrin
apachedex
Commits
9aa3b814
Commit
9aa3b814
authored
Apr 04, 2013
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Specify threshold in seconds.
parent
ab6cae21
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
apachedex/__init__.py
apachedex/__init__.py
+16
-12
No files found.
apachedex/__init__.py
View file @
9aa3b814
...
@@ -76,6 +76,7 @@ def getClassForStatusHit(hit, status):
...
@@ -76,6 +76,7 @@ def getClassForStatusHit(hit, status):
class
APDEXStats
(
object
):
class
APDEXStats
(
object
):
def
__init__
(
self
,
threshold
):
def
__init__
(
self
,
threshold
):
threshold
*=
US_PER_S
self
.
threshold
=
threshold
self
.
threshold
=
threshold
self
.
threshold4
=
threshold
*
APDEX_TOLERATING_COEF
self
.
threshold4
=
threshold
*
APDEX_TOLERATING_COEF
self
.
apdex_1
=
0
self
.
apdex_1
=
0
...
@@ -108,9 +109,12 @@ class APDEXStats(object):
...
@@ -108,9 +109,12 @@ class APDEXStats(object):
def
getAverage
(
self
):
def
getAverage
(
self
):
if
self
.
hit
:
if
self
.
hit
:
return
float
(
self
.
duration_total
)
/
self
.
hit
return
float
(
self
.
duration_total
)
/
(
US_PER_S
*
self
.
hit
)
return
0
return
0
def
getMax
(
self
):
return
float
(
self
.
duration_max
)
/
US_PER_S
class
GenericSiteStats
(
object
):
class
GenericSiteStats
(
object
):
def
__init__
(
self
,
threshold
,
prefix
=
1
,
error_detail
=
False
):
def
__init__
(
self
,
threshold
,
prefix
=
1
,
error_detail
=
False
):
self
.
threshold
=
threshold
self
.
threshold
=
threshold
...
@@ -151,8 +155,8 @@ class GenericSiteStats(object):
...
@@ -151,8 +155,8 @@ class GenericSiteStats(object):
for
data
in
self
.
apdex
.
itervalues
():
for
data
in
self
.
apdex
.
itervalues
():
apdex
.
accumulateFrom
(
data
)
apdex
.
accumulateFrom
(
data
)
return
[
return
[
(
date
,
apdex
.
getApdex
()
*
100
,
apdex
.
getAverage
()
/
US_PER_S
,
(
date
,
apdex
.
getApdex
()
*
100
,
apdex
.
getAverage
(),
float
(
apdex
.
duration_max
)
/
US_PER_S
,
apdex
.
hit
)
for
date
,
apdex
apdex
.
getMax
()
,
apdex
.
hit
)
for
date
,
apdex
in
sorted
(
self
.
apdex
.
iteritems
(),
key
=
ITEMGETTER0
)]
in
sorted
(
self
.
apdex
.
iteritems
(),
key
=
ITEMGETTER0
)]
def
asHTML
(
self
,
stat_filter
=
lambda
x
:
x
):
def
asHTML
(
self
,
stat_filter
=
lambda
x
:
x
):
...
@@ -166,8 +170,8 @@ class GenericSiteStats(object):
...
@@ -166,8 +170,8 @@ class GenericSiteStats(object):
'<p>Avg duration (s): %.2f</p><p>Max duration (s): %.2f</p>'
%
(
'<p>Avg duration (s): %.2f</p><p>Max duration (s): %.2f</p>'
%
(
apdex
.
hit
,
apdex
.
hit
,
apdex
.
getApdex
()
*
100
,
apdex
.
getApdex
()
*
100
,
apdex
.
getAverage
()
/
US_PER_S
,
apdex
.
getAverage
(),
float
(
apdex
.
duration_max
)
/
US_PER_S
,
apdex
.
getMax
()
,
))
))
column_set
=
set
()
column_set
=
set
()
filtered_status
=
defaultdict
(
partial
(
defaultdict
,
int
))
filtered_status
=
defaultdict
(
partial
(
defaultdict
,
int
))
...
@@ -303,9 +307,9 @@ class ERP5SiteStats(GenericSiteStats):
...
@@ -303,9 +307,9 @@ class ERP5SiteStats(GenericSiteStats):
apdex
*
100
,
apdex
*
100
,
data
.
hit
,
data
.
hit
,
getClassForDuration
(
data
.
getAverage
(),
self
.
threshold
),
getClassForDuration
(
data
.
getAverage
(),
self
.
threshold
),
data
.
getAverage
()
/
US_PER_S
,
data
.
getAverage
(),
getClassForDuration
(
data
.
duration_max
,
self
.
threshold
),
getClassForDuration
(
data
.
getMax
()
,
self
.
threshold
),
float
(
data
.
duration_max
)
/
US_PER_S
,
data
.
getMax
()
,
)
)
def
apdexAsColumns
(
data_dict
):
def
apdexAsColumns
(
data_dict
):
data_total
=
APDEXStats
(
self
.
threshold
)
data_total
=
APDEXStats
(
self
.
threshold
)
...
@@ -398,9 +402,9 @@ def main():
...
@@ -398,9 +402,9 @@ def main():
help
=
'Folder containing needed js files. Default: %(default)s'
)
help
=
'Folder containing needed js files. Default: %(default)s'
)
group
=
parser
.
add_argument_group
(
'generated content'
)
group
=
parser
.
add_argument_group
(
'generated content'
)
group
.
add_argument
(
'-a'
,
'--apdex'
,
default
=
US_PER_S
,
type
=
in
t
,
group
.
add_argument
(
'-a'
,
'--apdex'
,
default
=
1.0
,
type
=
floa
t
,
help
=
'First threshold for Apdex computation, in
micro
seconds. '
help
=
'First threshold for Apdex computation, in seconds. '
'Default: %(default)
r
'
)
'Default: %(default)
.2fs
'
)
group
.
add_argument
(
'-e'
,
'--error-detail'
,
action
=
'store_true'
,
group
.
add_argument
(
'-e'
,
'--error-detail'
,
action
=
'store_true'
,
help
=
'Include detailed report (url & referers) for error statuses.'
)
help
=
'Include detailed report (url & referers) for error statuses.'
)
group
.
add_argument
(
'-p'
,
'--period'
,
default
=
'day'
,
choices
=
period_parser
,
group
.
add_argument
(
'-p'
,
'--period'
,
default
=
'day'
,
choices
=
period_parser
,
...
@@ -550,7 +554,7 @@ def main():
...
@@ -550,7 +554,7 @@ def main():
out
.
write
(
'</head><body><h1>Overall</h1><h2>Parameters</h2>'
out
.
write
(
'</head><body><h1>Overall</h1><h2>Parameters</h2>'
'<table class="stats">'
)
'<table class="stats">'
)
for
caption
,
value
in
(
for
caption
,
value
in
(
(
'Apdex threshold'
,
'%.2fs'
%
(
float
(
args
.
apdex
)
/
US_PER_S
)
),
(
'Apdex threshold'
,
'%.2fs'
%
args
.
apdex
),
(
'Period'
,
args
.
period
),
(
'Period'
,
args
.
period
),
):
):
out
.
write
(
'<tr><th class="text">%s</th><td>%s</td></tr>'
%
(
out
.
write
(
'<tr><th class="text">%s</th><td>%s</td></tr>'
%
(
...
...
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