Commit 9aa3b814 authored by Vincent Pelletier's avatar Vincent Pelletier

Specify threshold in seconds.

parent ab6cae21
......@@ -76,6 +76,7 @@ def getClassForStatusHit(hit, status):
class APDEXStats(object):
def __init__(self, threshold):
threshold *= US_PER_S
self.threshold = threshold
self.threshold4 = threshold * APDEX_TOLERATING_COEF
self.apdex_1 = 0
......@@ -108,9 +109,12 @@ class APDEXStats(object):
def getAverage(self):
if self.hit:
return float(self.duration_total) / self.hit
return float(self.duration_total) / (US_PER_S * self.hit)
return 0
def getMax(self):
return float(self.duration_max) / US_PER_S
class GenericSiteStats(object):
def __init__(self, threshold, prefix=1, error_detail=False):
self.threshold = threshold
......@@ -151,8 +155,8 @@ class GenericSiteStats(object):
for data in self.apdex.itervalues():
apdex.accumulateFrom(data)
return [
(date, apdex.getApdex() * 100, apdex.getAverage() / US_PER_S,
float(apdex.duration_max) / US_PER_S, apdex.hit) for date, apdex
(date, apdex.getApdex() * 100, apdex.getAverage(),
apdex.getMax(), apdex.hit) for date, apdex
in sorted(self.apdex.iteritems(), key=ITEMGETTER0)]
def asHTML(self, stat_filter=lambda x: x):
......@@ -166,8 +170,8 @@ class GenericSiteStats(object):
'<p>Avg duration (s): %.2f</p><p>Max duration (s): %.2f</p>' % (
apdex.hit,
apdex.getApdex() * 100,
apdex.getAverage() / US_PER_S,
float(apdex.duration_max) / US_PER_S,
apdex.getAverage(),
apdex.getMax(),
))
column_set = set()
filtered_status = defaultdict(partial(defaultdict, int))
......@@ -303,9 +307,9 @@ class ERP5SiteStats(GenericSiteStats):
apdex * 100,
data.hit,
getClassForDuration(data.getAverage(), self.threshold),
data.getAverage() / US_PER_S,
getClassForDuration(data.duration_max, self.threshold),
float(data.duration_max) / US_PER_S,
data.getAverage(),
getClassForDuration(data.getMax(), self.threshold),
data.getMax(),
)
def apdexAsColumns(data_dict):
data_total = APDEXStats(self.threshold)
......@@ -398,9 +402,9 @@ def main():
help='Folder containing needed js files. Default: %(default)s')
group = parser.add_argument_group('generated content')
group.add_argument('-a', '--apdex', default=US_PER_S, type=int,
help='First threshold for Apdex computation, in microseconds. '
'Default: %(default)r')
group.add_argument('-a', '--apdex', default=1.0, type=float,
help='First threshold for Apdex computation, in seconds. '
'Default: %(default).2fs')
group.add_argument('-e', '--error-detail', action='store_true',
help='Include detailed report (url & referers) for error statuses.')
group.add_argument('-p', '--period', default='day', choices=period_parser,
......@@ -550,7 +554,7 @@ def main():
out.write('</head><body><h1>Overall</h1><h2>Parameters</h2>'
'<table class="stats">')
for caption, value in (
('Apdex threshold', '%.2fs' % (float(args.apdex) / US_PER_S)),
('Apdex threshold', '%.2fs' % args.apdex),
('Period', args.period),
):
out.write('<tr><th class="text">%s</th><td>%s</td></tr>' % (
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment