Commit 1b74aad6 authored by Vincent Pelletier's avatar Vincent Pelletier

Dates are not necessarily utc, apdex is not necessarily daily.

parent 8e1bd9f6
......@@ -128,12 +128,12 @@ class GenericSiteStats(object):
self.prefix = prefix
self.status = defaultdict(partial(defaultdict, int))
self.slowest_list = [(-1, None, None, None)]
self.daily_apdex = defaultdict(partial(APDEXStats, threshold))
self.apdex = defaultdict(partial(APDEXStats, threshold))
def accumulate(self, match, url_match, utcdate):
self.status[match.group('status')][utcdate] += 1
def accumulate(self, match, url_match, date):
self.status[match.group('status')][date] += 1
duration = match.group('duration')
self.daily_apdex[utcdate].accumulate(match)
self.apdex[date].accumulate(match)
if duration is not None:
duration = int(duration)
if url_match is None:
......@@ -154,19 +154,19 @@ class GenericSiteStats(object):
def getApdexData(self):
apdex = APDEXStats(self.threshold)
for data in self.daily_apdex.itervalues():
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
in sorted(self.daily_apdex.iteritems(), key=ITEMGETTER0)]
in sorted(self.apdex.iteritems(), key=ITEMGETTER0)]
def asHTML(self):
self._housekeeping()
result = []
append = result.append
apdex = APDEXStats(self.threshold)
for data in self.daily_apdex.itervalues():
for data in self.apdex.itervalues():
apdex.accumulateFrom(data)
append('<h2>Overall</h2><p>Hits: %i</p><p>Apdex: %i%%</p>'
'<p>Avg duration (s): %.2f</p><p>Max duration (s): %.2f</p>' % (
......@@ -225,14 +225,14 @@ class ERP5SiteStats(GenericSiteStats):
self.module = defaultdict(partial(defaultdict, partial(
defaultdict, partial(APDEXStats, threshold))))
def accumulate(self, match, url_match, utcdate):
def accumulate(self, match, url_match, date):
prefix = self.prefix
split = url_match.group('url').split('?', 1)[0].split('/')[1 + prefix:]
if split:
module = split[0]
if module.endswith('_module'):
super(ERP5SiteStats, self).accumulate(match, url_match, utcdate)
self.module[module][utcdate][len(split) > 2].accumulate(match)
super(ERP5SiteStats, self).accumulate(match, url_match, date)
self.module[module][date][len(split) > 2].accumulate(match)
def asHTML(self):
result = []
......@@ -439,13 +439,13 @@ def main():
if action is None:
skipped_lines += 1
continue
utcdate = asDate(match.group('timestamp'))
hit_per_day[utcdate] += 1
date = asDate(match.group('timestamp'))
hit_per_day[date] += 1
try:
site_data = per_site[site]
except KeyError:
site_data = per_site[site] = action(threshold)
site_data.accumulate(match, url_match, utcdate)
site_data.accumulate(match, url_match, date)
all_lines += lineno
end_parsing_time = time.time()
os.chdir(args.out)
......
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