summaryrefslogtreecommitdiff
path: root/tests/old/refcount.py
blob: 70adc0c13ac8a46c49830b4a9f77066ce3a54a44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python-dbg

from pprint import pprint
import apt
import sys
import gc

# 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))