Commits

Lukas Diekmann  committed dde10a8

added dict referents test

  • Participants
  • Parent commits 93d885c

Comments (0)

Files changed (1)

File test_dict_referents.py

+import gc
+from libbench import analysis
+
+def test_count_referents():
+
+    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 id(d) in c.seen
+    assert c.num[str(int)] > 1000
+    print "ints", c.num[str(int)]
+
+    c = Collector()
+    c.walk_obj({"a": d, 1:2})
+    assert d in c.deferred_dicts
+    c.finish()
+    #assert id(d) in c.seen
+    assert c.num[str(int)] == 1000
+