diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 18:07:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 18:07:41 +0000 |
commit | 76926159194e180003aa78de97e5f287bf4325a5 (patch) | |
tree | 2cea7245cdc3f66355900c820c145eba90598766 /tests/old/refcount.py | |
parent | Initial commit. (diff) | |
download | python-apt-76926159194e180003aa78de97e5f287bf4325a5.tar.xz python-apt-76926159194e180003aa78de97e5f287bf4325a5.zip |
Adding upstream version 2.7.6.upstream/2.7.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/old/refcount.py')
-rwxr-xr-x | tests/old/refcount.py | 54 |
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)) |