Commit 35aaa2c9 authored by Vincent Pelletier's avatar Vincent Pelletier

Implement logarythmic Y scale for hits.

Makes error plot more readable when there are very few errors.
parent 50ddac56
......@@ -186,7 +186,7 @@ def prepareDataForGraph(daily_data, date_format, placeholder_delta,
return new_daily_data
def graphPair(daily_data, date_format, graph_period, apdex_y_min=None,
hit_y_min=None, hit_y_max=None, apdex_y_scale=None):
hit_y_min=None, hit_y_max=None, apdex_y_scale=None, hit_y_scale=None):
date_list = [int(calendar.timegm(time.strptime(x[0], date_format)) * 1000)
for x in daily_data]
timeformat = '%Y/<br/>%m/%d<br/> %H:%M'
......@@ -240,6 +240,7 @@ def graphPair(daily_data, date_format, graph_period, apdex_y_min=None,
'axisLabel': 'Hits',
'labelWidth': yLabelWidth,
'tickDecimals': 0,
'transform': hit_y_scale,
},
'lines': {'show': True},
'grid': {
......@@ -405,7 +406,7 @@ class GenericSiteStats(object):
graph_coefficient, encoding, stat_filter=lambda x: x,
x_min=None, x_max=None,
apdex_y_min=None, hit_y_min=None, hit_y_max=None,
apdex_y_scale=None,
apdex_y_scale=None, hit_y_scale=None,
):
result = []
append = result.append
......@@ -597,7 +598,7 @@ class ERP5SiteStats(GenericSiteStats):
def asHTML(self, date_format, placeholder_delta, graph_period, graph_coefficient,
encoding, stat_filter=lambda x: x, x_min=None, x_max=None,
apdex_y_min=None, hit_y_min=None, hit_y_max=None,
apdex_y_scale=None,
apdex_y_scale=None, hit_y_scale=None,
):
result = []
append = result.append
......@@ -666,6 +667,7 @@ class ERP5SiteStats(GenericSiteStats):
hit_y_min=hit_y_min,
hit_y_max=hit_y_max,
apdex_y_scale=apdex_y_scale,
hit_y_scale=hit_y_scale,
))
append('</div></div>')
append('</td>')
......@@ -704,6 +706,7 @@ class ERP5SiteStats(GenericSiteStats):
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,
apdex_y_scale=apdex_y_scale,
hit_y_scale=hit_y_scale,
))
return '\n'.join(result)
......@@ -1008,6 +1011,11 @@ apdex_y_scale_dict = {
'log': 'log100To0',
}
hit_y_scale_dict = {
'linear': None,
'log': 'log0ToAny',
}
def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
stats, site_caption_dict):
period = period_parameter_dict['period']
......@@ -1044,6 +1052,7 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
out.write('<script type="text/javascript" src="%s/%s"></script>' % (
js_path, script))
apdex_y_scale = apdex_y_scale_dict[args.apdex_yscale]
hit_y_scale = hit_y_scale_dict[args.hit_yscale]
out.write('</head><body><h1>Overall</h1>')
site_list = list(enumerate(sorted(per_site.iteritems(),
key=lambda x: site_caption_dict[x[0]])))
......@@ -1102,6 +1111,7 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
hit_y_min=hit_y_min,
hit_y_max=hit_y_max,
apdex_y_scale=apdex_y_scale,
hit_y_scale=hit_y_scale,
)
)
out.write(data.asHTML(date_format, placeholder_delta, graph_period,
......@@ -1109,6 +1119,7 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
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,
apdex_y_scale=apdex_y_scale,
hit_y_scale=hit_y_scale,
))
end_stat_time = time.time()
if args.stats:
......@@ -1196,6 +1207,9 @@ def main():
group.add_argument('--apdex-yscale', default='linear',
choices=apdex_y_scale_dict,
help='apdex graph ordinate scale. Default: %(default)s')
group.add_argument('--hit-yscale', default='linear',
choices=hit_y_scale_dict,
help='hit graph ordinate scale. Default: %(default)s')
group = parser.add_argument_group('site matching', 'Earlier arguments take '
'precedence. Arguments are Python regexes, matching urlencoded strings.'
......
......@@ -28,6 +28,10 @@ scale_map = {
log100To0: [
function (v) { return -Math.log(101 - v); },
function (v) { return 101 - Math.exp(-v); }
],
log0ToAny: [
function (v) { return Math.log(v + 1); },
function (v) { return Math.exp(v) - 1; }
]
}
......
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