from __future__ import print_function
import sys, os
import Image, ImageDraw
-from xml.sax import ContentHandler, saxutils, make_parser
+from xml.sax import ContentHandler, make_parser
from xml.sax.handler import feature_namespaces
from optparse import OptionParser
assert kind == 'old'
if self.width <= 0:
self.width = (size + chunk_size - 1) / chunk_size
- else:
- assert self.width == (size + chunk_size - 1) / chunk_size
+ if self.width < 128:
+ self.width = 512
+ self.current_section_size = size
+ else:
+ self.current_section_size = self.width * chunk_size
self.size += size
def add_object (self, klass, offset, size):
SectionHandler.add_occupied (self, self.offset + offset, size)
def end_section (self):
- self.offset += self.width * chunk_size
+ self.offset += self.current_section_size
def header (self):
return 'old sections'
class LargeSectionHandler (SectionHandler):
def __init__ (self):
- SectionHandler.__init__ (self, 500)
+ SectionHandler.__init__ (self, 512)
def start_section (self, kind, size):
self.kind = kind
def header (self):
return self.kind + ' section'
-class DocHandler (saxutils.DefaultHandler):
+class DocHandler (ContentHandler):
def start (self):
self.collection_index = 0
self.index_file = open ('index.html', 'w')
self.usage = {}
self.los_usage = {}
self.pinned_usage = {}
+ self.occupancies = {}
self.in_los = False
self.in_pinned = False
self.heap_used = 0
kind = attrs.get('type', None)
bytes = int(attrs.get('bytes', None))
print ('Pinned from %s: %d kB<br>' % (kind, bytes / 1024), file = self.collection_file)
+ elif name == 'occupancy':
+ size = int (attrs.get ('size', None))
+ available = int (attrs.get ('available', None))
+ used = int (attrs.get ('used', None))
+ unused = available - used
+
+ print ('Occupancy of %d byte slots: %d / %d (%d kB / %d%% wasted)<br>' % (size, used, available, unused * size / 1024, unused * 100 / available), file = self.collection_file)
elif name == 'section':
kind = attrs.get('type', None)
size = int(attrs.get('size', None))