[Moin-devel] CVS: MoinMoin/stats pagesize.py,1.1,1.2
J?rgen Hermann
jhermann at users.sourceforge.net
Fri Feb 1 21:34:24 EST 2002
Update of /cvsroot/moin/MoinMoin/stats
In directory usw-pr-cvs1:/tmp/cvs-serv23842
Modified Files:
pagesize.py
Log Message:
Adaptive scale
Index: pagesize.py
===================================================================
RCS file: /cvsroot/moin/MoinMoin/stats/pagesize.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** pagesize.py 2002/02/02 04:29:55 1.1
--- pagesize.py 2002/02/02 05:32:15 1.2
***************
*** 37,42 ****
def draw(pagename, form):
! import cgi, sys, shutil, cStringIO
from MoinMoin import config, webapi
from MoinMoin.stats.chart import Chart, ChartData, Color
--- 37,49 ----
+ def _slice(data, lo, hi):
+ data = data[:]
+ if lo: data[:lo] = [None] * lo
+ if hi < len(data): data[hi:] = [None] * (len(data)-hi)
+ return data
+
+
def draw(pagename, form):
! import bisect, cgi, sys, shutil, cStringIO
from MoinMoin import config, webapi
from MoinMoin.stats.chart import Chart, ChartData, Color
***************
*** 48,65 ****
sizes = [(p.size(), name) for name, p in pages.items()]
sizes.sort()
- upper_bound = int((sizes[-1][0] + 1023) / 1024) * 1024.0
! classes = 20
! data = [None] * classes
for size, name in sizes:
! idx = int((size / upper_bound) * classes)
data[idx] = (data[idx] or 0) + 1
! labels = []
! for idx in range(classes):
! label = "%.1f" % (
! upper_bound / classes * (idx+1) / 1024,
! )
! labels.append(label)
# give us a chance to develop this
--- 55,75 ----
sizes = [(p.size(), name) for name, p in pages.items()]
sizes.sort()
! upper_bound = sizes[-1][0]
! bounds = [s*128 for s in range(1, 9)]
! if upper_bound >= 1024:
! bounds.extend([s*1024 for s in range(2, 9)])
! if upper_bound >= 8192:
! bounds.extend([s*8192 for s in range(2, 9)])
! if upper_bound >= 65536:
! bounds.extend([s*65536 for s in range(2, 9)])
!
! data = [None] * len(bounds)
for size, name in sizes:
! idx = bisect.bisect(bounds, size)
! ##idx = int((size / upper_bound) * classes)
data[idx] = (data[idx] or 0) + 1
! labels = ["%d" %b for b in bounds]
# give us a chance to develop this
***************
*** 71,92 ****
image = cStringIO.StringIO()
c = Chart()
! c.addData(ChartData(data, 'green'))
title = ''
if config.sitename: title = "%s: " % config.sitename
title = title + 'Page Size Distribution'
c.option(
! annotation = (len(labels)-1, Color('black'), "%d %s" % sizes[-1]),
title = title,
! xtitle = 'page size upper bound [K]',
ytitle = '# of pages of this size',
title_font = c.GDC_GIANT,
! #thumblabel = 'THUMB', thumbnail = 1, thumbval = 10,
! #ytitle_color = Color('green'),
! #yaxis2 = 1,
! #ytitle2 = '# of edits',
! #ytitle2_color = Color('red'),
! #ylabel2_color = Color('black'),
requested_yinterval = 1.0,
! stack_type = c.GDC_STACK_BESIDE
)
c.draw(style,
--- 81,104 ----
image = cStringIO.StringIO()
c = Chart()
! ##c.addData(ChartData(data, 'magenta'))
! c.addData(ChartData(_slice(data, 0, 7), 'blue'))
! if upper_bound >= 1024:
! c.addData(ChartData(_slice(data, 7, 14), 'green'))
! if upper_bound >= 8192:
! c.addData(ChartData(_slice(data, 14, 21), 'red'))
! if upper_bound >= 65536:
! c.addData(ChartData(_slice(data, 21, 28), 'magenta'))
title = ''
if config.sitename: title = "%s: " % config.sitename
title = title + 'Page Size Distribution'
c.option(
! annotation = (bisect.bisect(bounds, upper_bound), Color('black'), "%d %s" % sizes[-1]),
title = title,
! xtitle = 'page size upper bound [bytes]',
ytitle = '# of pages of this size',
title_font = c.GDC_GIANT,
! threed_depth = 2.0,
requested_yinterval = 1.0,
! stack_type = c.GDC_STACK_LAYER
)
c.draw(style,
More information about the Moin-devel
mailing list