Author: Carl Friedrich Bolz <cfb...@gmx.de> Branch: statistics-maps Changeset: r82170:c5af13624160 Date: 2016-02-12 12:32 +0100 http://bitbucket.org/pypy/pypy/changeset/c5af13624160/
Log: weed out some fake transitions, log size_estimate, fix some corner cases, draw back arrow diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py --- a/pypy/objspace/std/mapdict.py +++ b/pypy/objspace/std/mapdict.py @@ -93,6 +93,7 @@ lines = ["{"] lines.append(_print_line('type', self.__class__.__name__, 1)) lines.append(_print_line('id', str(objectmodel.compute_unique_id(self)), 1)) + lines.append(_print_line('size_estimate', str(self.size_estimate()), 1)) lines.append(_print_line('instances', self._number_instantiated, 1)) if isinstance(self, PlainAttribute): lines.append(_print_line('back', str(objectmodel.compute_unique_id(self.back)), 1)) @@ -170,7 +171,8 @@ attr = self.find_map_attr(name, index) if attr is None: return self.terminator._write_terminator(obj, name, index, w_value) - attr._count_write(name, index, w_value) + if type(obj) is not Object: + attr._count_write(name, index, w_value) # if the write is not necessary, the storage is already filled from the # time we did the map transition. Therefore, if the value profiler says # so, we can not do the write @@ -304,7 +306,8 @@ def add_attr(self, obj, name, index, w_value): # grumble, jit needs this attr = self._get_new_attr(name, index) - attr._count_write(name, index, w_value) + if type(obj) is not Object: + attr._count_write(name, index, w_value) oldattr = obj._get_mapdict_map() if not jit.we_are_jitted(): size_est = (oldattr._size_estimate + attr.size_estimate() @@ -601,7 +604,8 @@ return jit.promote(self.map) def _set_mapdict_map(self, map): old = self.map - if old is not map and map: + # don't count Object, it's just an intermediate + if old is not map and map and type(self) is not Object: old._count_transition(map) self.map = map # _____________________________________________ diff --git a/pypy/tool/mapstatsdot.py b/pypy/tool/mapstatsdot.py --- a/pypy/tool/mapstatsdot.py +++ b/pypy/tool/mapstatsdot.py @@ -60,6 +60,8 @@ return seen.add(self) if hasattr(self, 'back'): + if self not in self.back.transitions: + output.edge(self.back.id, self.id, dir="none") self.back.dot(output, seen) if not self.instances: return @@ -107,7 +109,7 @@ if writes: for tup, count in writes.iteritems(): key, index, cls = tup.strip('()').split(', ') - if key.startswith('"'): + if key.startswith(('"', "'")): key = eval(key) assert key == self.name assert int(index) == self.nametype @@ -120,7 +122,7 @@ assert len(reads) == 1 for tup, count in reads.iteritems(): key, index = tup.strip('()').split(', ') - if key.startswith('"'): + if key.startswith(('"', "'")): key = eval(key) assert key == self.name assert int(index) == self.nametype _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit