Author: Anton Gulenko <anton.gule...@googlemail.com>
Branch: storage
Changeset: r807:d6c359685152
Date: 2014-05-07 15:16 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/d6c359685152/

Log:    Fixed initialization of strategy statistics and the test.

diff --git a/spyvm/storage_statistics.py b/spyvm/storage_statistics.py
--- a/spyvm/storage_statistics.py
+++ b/spyvm/storage_statistics.py
@@ -13,8 +13,10 @@
             return a[0] < b[0]
 
 class StorageStatistics(object):
-    modules = []
-    using_classname = False
+    
+    def __init__(self):
+        self.modules = []
+        self.using_classname = False
     
     def add_module(self, module):
         if module not in self.modules:
@@ -73,7 +75,9 @@
         pass
 
 class AbstractStatisticsCollector(StatisticsModule):
-    stats = {}
+    
+    def __init__(self):
+        self.stats = {}
     
     def storage_operation(self, operation_key, storage_size, 
element_classname):
         if not operation_key in self.stats:
@@ -100,10 +104,14 @@
             print "\t%s: %d times, avg size: %f" % (self.key_string(key), num, 
float(sum)/num)
 
 class DotStatisticsCollector(StatisticsCollector):
-    incoming_operations = {}
-    incoming_elements = {}
-    outgoing_operations = {}
-    outgoing_elements = {}
+    
+    def __init__(self):
+        AbstractStatisticsCollector.__init__(self)
+        self.incoming_operations = {}
+        self.incoming_elements = {}
+        self.outgoing_operations = {}
+        self.outgoing_elements = {}
+    
     def storage_operation(self, key, storage_size, element_classname):
         StatisticsCollector.storage_operation(self, key, storage_size, 
element_classname)
         source_type = key[1]
diff --git a/spyvm/test/test_strategies.py b/spyvm/test/test_strategies.py
--- a/spyvm/test/test_strategies.py
+++ b/spyvm/test/test_strategies.py
@@ -218,5 +218,7 @@
     col.storage_operation(stats.make_key("Filledin", None, "new"), 10, None)
     col.storage_operation(stats.make_key("Filledin", None, "new"), 11, None)
     
-    assert col.dot_string() == ""
+    # The dot-code is correct, I checked ;)
+    assert col.dot_string() == \
+    'digraph G {loading_image [label="Image Loading",shape=box];created_object 
[label="Object Creation",shape=box];created_object -> old2 [label="1 
objects\n15 elements per object"];loading_image -> new [label="2 objects\n10 
elements per object"];old -> new [label="2 objects\n10 elements per object\n66% 
objects\n60% elements"];loading_image -> old2 [label="1 objects\n20 elements 
per object"];created_object -> old [label="3 objects\n11 elements per 
object"];old2 -> new [label="1 objects\n5 elements per object\n50% objects\n14% 
elements"];new -> new2 [label="1 objects\n10 elements per object\n20% 
objects\n21% elements"];new2 [label="new2\nIncoming objects: 1\nIncoming 
elements: 10\nRemaining objects: 1 (100%)\nRemaining elements: 10 (100%)"];new 
[label="new\nIncoming objects: 5\nIncoming elements: 46\nRemaining objects: 4 
(80%)\nRemaining elements: 36 (78%)"];old2 [label="old2\nIncoming objects: 
2\nIncoming elements: 35\nRemaining objects: 1 (50%)\nRemaining elements: 30 
(85%)"];old [
 label="old\nIncoming objects: 3\nIncoming elements: 33\nRemaining objects: 1 
(33%)\nRemaining elements: 13 (39%)"];}'
     
\ No newline at end of file
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to