summaryrefslogtreecommitdiffstats
path: root/tests/old/refcount.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/old/refcount.py')
-rwxr-xr-xtests/old/refcount.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/old/refcount.py b/tests/old/refcount.py
new file mode 100755
index 0000000..0fad676
--- /dev/null
+++ b/tests/old/refcount.py
@@ -0,0 +1,54 @@
+#!/usr/bin/python-dbg
+
+import gc
+import sys
+from pprint import pprint
+
+import apt
+
+# get initial cache
+print(sys.gettotalrefcount())
+progress = apt.progress.OpTextProgress()
+c = apt.Cache(progress)
+print("refcount after first cache instance: ", sys.gettotalrefcount())
+
+# test open()
+c.open(progress)
+print("refcount after cache open: ", sys.gettotalrefcount())
+# pprint(sys.getobjects(10))
+
+c.open(apt.progress.OpProgress())
+print("refcount after seconf cache open: ", sys.gettotalrefcount())
+# pprint(sys.getobjects(10))
+
+# FIXME: find a way to get a efficient diff
+# before = gc.get_objects()
+# c.open(apt.progress.OpProgress())
+# after = gc.get_objects()
+
+
+# test update()
+print("refcount before cache.update(): ", sys.gettotalrefcount())
+c.update()
+gc.collect()
+print("refcount after cache.update(): ", sys.gettotalrefcount())
+c.update()
+gc.collect()
+print("refcount after second cache.update(): ", sys.gettotalrefcount())
+# pprint(sys.getobjects(20))
+
+
+# test install()
+c.open(apt.progress.OpProgress())
+gc.collect()
+print("refcount before cache['hello'].mark_install(): ", sys.gettotalrefcount())
+c["hello"].mark_install()
+c.commit(apt.progress.FetchProgress(), apt.progress.InstallProgress())
+gc.collect()
+print("refcount after: ", sys.gettotalrefcount())
+c.open(apt.progress.OpProgress())
+c["hello"].mark_delete()
+c.commit(apt.progress.FetchProgress(), apt.progress.InstallProgress())
+gc.collect()
+print("refcount after: ", sys.gettotalrefcount())
+pprint(sys.getobjects(10))