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