diff --git a/apachedex/__init__.py b/apachedex/__init__.py
index 3484c53e05b40f44cb5b3211fba3314159fbbb26..1c183fcf03bf96ccf7a63cebdcf68b88bca57873 100755
--- a/apachedex/__init__.py
+++ b/apachedex/__init__.py
@@ -116,7 +116,7 @@ MONTH_VALUE_DICT = dict((y, x) for (x, y) in enumerate(('Jan', 'Feb', 'Mar',
US_PER_S = 10 ** 6
-N_SLOWEST = 20
+N_HOTTEST_PAGES_DEFAULT = 20
N_ERROR_URL = 10
N_REFERRER_PER_ERROR_URL = 5
N_USER_AGENT = 20
@@ -409,6 +409,7 @@ class GenericSiteStats(object):
x_min=None, x_max=None,
apdex_y_min=None, hit_y_min=None, hit_y_max=None,
apdex_y_scale=None, hit_y_scale=None,
+ n_hottest_pages=N_HOTTEST_PAGES_DEFAULT,
):
result = []
append = result.append
@@ -423,7 +424,7 @@ class GenericSiteStats(object):
append(APDEXStats.asHTMLHeader())
append('
url | ')
for url, data in sorted(self.url_apdex.iteritems(), key=lambda x: x[1].getAverage() * x[1].hit,
- reverse=True)[:N_SLOWEST]:
+ reverse=True)[:n_hottest_pages]:
append('')
append(data.asHTML(self.threshold))
append('%s |
' % escape(url))
@@ -605,6 +606,7 @@ class ERP5SiteStats(GenericSiteStats):
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, hit_y_scale=None,
+ n_hottest_pages=N_HOTTEST_PAGES_DEFAULT,
):
result = []
append = result.append
@@ -713,6 +715,7 @@ class ERP5SiteStats(GenericSiteStats):
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,
+ n_hottest_pages=n_hottest_pages,
))
return '\n'.join(result)
@@ -1106,6 +1109,7 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
for hit_date, hit in sorted(hit_per_day.iteritems(), key=ITEMGETTER0):
out.write('%s | %s |
' % (hit_date, hit))
out.write('')
+ n_hottest_pages = args.n_hottest_pages
for i, (site_id, data) in site_list:
out.write('%s
' % (i, escape(repr(site_id),
quote=True), html_site_caption_dict[site_id]))
@@ -1136,6 +1140,7 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
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,
+ n_hottest_pages=n_hottest_pages,
))
end_stat_time = time.time()
if args.stats:
@@ -1283,6 +1288,9 @@ def main():
group.add_argument('--hit-yscale', default='linear',
choices=hit_y_scale_dict,
help='hit graph ordinate scale. Default: %(default)s')
+ group.add_argument('--n-hottest-pages', type=int,
+ default=N_HOTTEST_PAGES_DEFAULT,
+ help='Number of hottest pages to display.')
group = parser.add_argument_group('site matching', 'Earlier arguments take '
'precedence. Arguments are Python regexes, matching urlencoded strings.'