r19809 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r19808‎ | r19809 | r19810 >
Date:01:02, 7 February 2007
Author:brion
Status:old
Tags:
Comment:
multiple reports...
Modified paths:
  • /trunk/tools/bandbreakdown/bandbreakdown.py (modified) (history)

Diff [purge]

Index: trunk/tools/bandbreakdown/bandbreakdown.py
@@ -15,21 +15,36 @@
1616 groups = [group for (group, regex) in matchTypes]
1717 groups.append("other")
1818
19 -totalHits = 0
20 -totalBytes = 0
21 -hits = {}
22 -bytes = {}
 19+interval = 1000
 20+
 21+hits = {"total": 0}
 22+bytes = {"total": 0}
2323 for group in groups:
2424 hits[group] = 0
2525 bytes[group] = 0
2626
 27+def dump(groups, hits, bytes):
 28+ print "--"
 29+ if hits["total"] == 0 or bytes["total"] == 0:
 30+ print "no hits detected :("
 31+
 32+ for group in groups:
 33+ if hits[group] > 0:
 34+ print "%12s %8d hits (%6.2f%%) %16d bytes (%6.2f%%) %10.1f bytes/hit" % (
 35+ group,
 36+ hits[group],
 37+ 100.0 * float(hits[group]) / float(hits["total"]),
 38+ bytes[group],
 39+ 100.0 * float(bytes[group]) / float(bytes["total"]),
 40+ float(bytes[group]) / float(hits[group]))
 41+
2742 for line in sys.stdin:
2843 matches = lineSplit.match(line)
2944 if matches:
3045 size = int(matches.group(1))
3146 url = matches.group(2)
32 - totalHits += 1
33 - totalBytes += size
 47+ hits["total"] += 1
 48+ bytes["total"] += size
3449 for (group, regex) in matchTypes:
3550 if regex.match(url):
3651 hits[group] += 1
@@ -38,16 +53,8 @@
3954 else:
4055 hits["other"] += 1
4156 bytes["other"] += size
 57+ if hits["total"] % interval == 0:
 58+ dump(groups, hits, bytes)
4259
43 -if totalHits == 0 or totalBytes == 0:
44 - print "no hits detected :("
45 -
46 -for group in groups:
47 - if hits[group] > 0:
48 - print "%12s %8d hits (%6.2f%%) %16d bytes (%6.2f%%) %10.1f bytes/hit" % (
49 - group,
50 - hits[group],
51 - 100.0 * float(hits[group]) / float(totalHits),
52 - bytes[group],
53 - 100.0 * float(bytes[group]) / float(totalBytes),
54 - float(bytes[group]) / float(hits[group]))
 60+if hits["total"] % interval != 0:
 61+ dump(groups, hits, bytes)