Commit 0b5086cf authored by Vincent Pelletier's avatar Vincent Pelletier

Add a parameter to fix y range on all graphs.

Default behaviour doesn't change.
If --fixed-yrange is provided with a negative value (default), ymax is
left floating.
If --fixed-yrange is provided with a value, ymax is fixed at that value.
parent b4cd8161
...@@ -130,7 +130,8 @@ def prepareDataForGraph(daily_data, date_format, placeholder_delta, ...@@ -130,7 +130,8 @@ def prepareDataForGraph(daily_data, date_format, placeholder_delta,
append((x_max, 100, 0)) append((x_max, 100, 0))
return new_daily_data return new_daily_data
def graphPair(daily_data, date_format, graph_period): def graphPair(daily_data, date_format, graph_period, apdex_y_min=None,
hit_y_min=None, hit_y_max=None):
date_list = [int(calendar.timegm(time.strptime(x[0], date_format)) * 1000) date_list = [int(calendar.timegm(time.strptime(x[0], date_format)) * 1000)
for x in daily_data] for x in daily_data]
timeformat = '%Y/<br/>%m/%d<br/> %H:%M' timeformat = '%Y/<br/>%m/%d<br/> %H:%M'
...@@ -149,6 +150,7 @@ def graphPair(daily_data, date_format, graph_period): ...@@ -149,6 +150,7 @@ def graphPair(daily_data, date_format, graph_period):
'minTickSize': minTickSize, 'minTickSize': minTickSize,
}, },
'yaxis': { 'yaxis': {
'min': apdex_y_min,
'max': 100, 'max': 100,
'axisLabel': 'apdex (%)', 'axisLabel': 'apdex (%)',
'labelWidth': yLabelWidth, 'labelWidth': yLabelWidth,
...@@ -167,6 +169,8 @@ def graphPair(daily_data, date_format, graph_period): ...@@ -167,6 +169,8 @@ def graphPair(daily_data, date_format, graph_period):
'minTickSize': minTickSize, 'minTickSize': minTickSize,
}, },
'yaxis': { 'yaxis': {
'min': hit_y_min,
'max': hit_y_max,
'axisLabel': 'Hits', 'axisLabel': 'Hits',
'labelWidth': yLabelWidth, 'labelWidth': yLabelWidth,
'tickDecimals': 0, 'tickDecimals': 0,
...@@ -330,6 +334,7 @@ class GenericSiteStats(object): ...@@ -330,6 +334,7 @@ class GenericSiteStats(object):
def asHTML(self, date_format, placeholder_delta, graph_period, def asHTML(self, date_format, placeholder_delta, graph_period,
graph_coefficient, encoding, stat_filter=lambda x: x, graph_coefficient, encoding, stat_filter=lambda x: x,
x_min=None, x_max=None, x_min=None, x_max=None,
apdex_y_min=None, hit_y_min=None, hit_y_max=None,
): ):
result = [] result = []
append = result.append append = result.append
...@@ -522,6 +527,7 @@ class ERP5SiteStats(GenericSiteStats): ...@@ -522,6 +527,7 @@ class ERP5SiteStats(GenericSiteStats):
def asHTML(self, date_format, placeholder_delta, graph_period, graph_coefficient, def asHTML(self, date_format, placeholder_delta, graph_period, graph_coefficient,
encoding, stat_filter=lambda x: x, x_min=None, x_max=None, encoding, stat_filter=lambda x: x, x_min=None, x_max=None,
apdex_y_min=None, hit_y_min=None, hit_y_max=None,
): ):
result = [] result = []
append = result.append append = result.append
...@@ -586,6 +592,9 @@ class ERP5SiteStats(GenericSiteStats): ...@@ -586,6 +592,9 @@ class ERP5SiteStats(GenericSiteStats):
), ),
date_format, date_format,
graph_period, graph_period,
apdex_y_min=apdex_y_min,
hit_y_min=hit_y_min,
hit_y_max=hit_y_max,
)) ))
append('</div></div>') append('</div></div>')
append('</td>') append('</td>')
...@@ -622,6 +631,7 @@ class ERP5SiteStats(GenericSiteStats): ...@@ -622,6 +631,7 @@ class ERP5SiteStats(GenericSiteStats):
placeholder_delta, graph_period, graph_coefficient, encoding, placeholder_delta, graph_period, graph_coefficient, encoding,
stat_filter=stat_filter, stat_filter=stat_filter,
x_min=x_min, x_max=x_max, x_min=x_min, x_max=x_max,
apdex_y_min=apdex_y_min, hit_y_min=hit_y_min, hit_y_max=hit_y_max,
)) ))
return '\n'.join(result) return '\n'.join(result)
...@@ -882,6 +892,11 @@ period_parser = { ...@@ -882,6 +892,11 @@ period_parser = {
unquoteToHtml = lambda x, encoding: escape(unquote(x).decode(encoding, unquoteToHtml = lambda x, encoding: escape(unquote(x).decode(encoding,
'replace')) 'replace'))
apdex_y_scale_dict = {
'linear': None,
'log': 'log100To0',
}
def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict, def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
stats, site_caption_dict): stats, site_caption_dict):
period = period_parameter_dict['period'] period = period_parameter_dict['period']
...@@ -890,6 +905,13 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict, ...@@ -890,6 +905,13 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
placeholder_delta = period_parameter_dict['placeholder_delta'] placeholder_delta = period_parameter_dict['placeholder_delta']
graph_period = period_parameter_dict['graph_period'] graph_period = period_parameter_dict['graph_period']
graph_coefficient = period_parameter_dict['graph_coefficient'] graph_coefficient = period_parameter_dict['graph_coefficient']
hit_y_max = args.fixed_yrange
if hit_y_max is not None:
apdex_y_min = hit_y_min = 0
if hit_y_max < 0:
hit_y_max = None
else:
apdex_y_min = hit_y_min = None
out.write('<!DOCTYPE html>\n<html><head><meta charset="%s">' out.write('<!DOCTYPE html>\n<html><head><meta charset="%s">'
'<title>Stats</title>' % encoding) '<title>Stats</title>' % encoding)
js_path = getattr(args, 'js', None) js_path = getattr(args, 'js', None)
...@@ -964,11 +986,15 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict, ...@@ -964,11 +986,15 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
), ),
date_format, date_format,
graph_period, graph_period,
apdex_y_min=apdex_y_min,
hit_y_min=hit_y_min,
hit_y_max=hit_y_max,
) )
) )
out.write(data.asHTML(date_format, placeholder_delta, graph_period, out.write(data.asHTML(date_format, placeholder_delta, graph_period,
graph_coefficient, encoding, decimator, graph_coefficient, encoding, decimator,
x_min=x_min, x_max=x_max, x_min=x_min, x_max=x_max,
apdex_y_min=apdex_y_min, hit_y_min=hit_y_min, hit_y_max=hit_y_max,
)) ))
end_stat_time = time.time() end_stat_time = time.time()
if args.stats: if args.stats:
...@@ -1071,6 +1097,10 @@ def main(): ...@@ -1071,6 +1097,10 @@ def main():
help='Folder containing needed js files. Default: %(default)s') help='Folder containing needed js files. Default: %(default)s')
group.add_argument('--js-embed', action='store_true', group.add_argument('--js-embed', action='store_true',
help='Embed js files instead of linking to them.') help='Embed js files instead of linking to them.')
group.add_argument('--fixed-yrange', nargs='?', type=int, const=-1,
help='Fix graph vertical range: 0-100%% for apdex, 0-value for hits. '
'Negative value means hit max is adapted to data (used when this '
'argument is provided without value).')
group = parser.add_argument_group('site matching', 'Earlier arguments take ' group = parser.add_argument_group('site matching', 'Earlier arguments take '
'precedence. For example: --skip-base "/foo/bar(/|$|\\?)" ' 'precedence. For example: --skip-base "/foo/bar(/|$|\\?)" '
......
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