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

Specify threshold in seconds.

parent ab6cae21
...@@ -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=int, group.add_argument('-a', '--apdex', default=1.0, type=float,
help='First threshold for Apdex computation, in microseconds. ' 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>' % (
......
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