Commits

Lukas Diekmann  committed 2a8c08d

added dict referents test

  • Participants
  • Parent commits abbde89

Comments (0)

Files changed (1)

File libbench/test/test_analysis.py

     assert output[0][0] == "full"
     assert output[0][1][0][1:-1] == (clsname, a2[clsname], 21456, a2[clsname] / 21456.)
 
+def test_histogram_dict_referents():
+    from libbench import analysis
+
+    Collector = analysis.HeapCollector
+
+    Analysis = analysis.TypeSizeHistograms
+    ana = Analysis()
+
+
+    d = {}.fromkeys(xrange(1000))
+
+    c = Collector()
+    for obj in gc.get_objects():
+        c.walk_obj(obj)
+
+    assert d in c.deferred_dicts
+    assert c.num[str(int)] > 1000
+
+    c = Collector()
+    c.walk_obj({"a": d, 1:2})
+
+    assert d in c.deferred_dicts # dicts are counted later in finish
+    assert c.num[str(int)] == 1000 # but their referents should be counted here
+
 def test_instance_has_dict():
 
     # this should have a dict