summaryrefslogtreecommitdiff
path: root/test/aaa_profiling
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-11-26 23:24:13 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2013-11-26 23:24:13 -0500
commit30a50cc46aa836e24ebcbb889cbee583c511af82 (patch)
tree053c2af8e82434c1e7a616e1a1c55b819aad244b /test/aaa_profiling
parent6029496bd3fb78caeab349ef8df5b58f058db16e (diff)
downloadsqlalchemy-30a50cc46aa836e24ebcbb889cbee583c511af82.tar.gz
- the wrapped memoized_property here was not working, as the attribute name
didn't match. use straight memoized_props here for now, add a perf test to check it
Diffstat (limited to 'test/aaa_profiling')
-rw-r--r--test/aaa_profiling/test_orm.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/aaa_profiling/test_orm.py b/test/aaa_profiling/test_orm.py
index 6d71468b7..2c1e84afb 100644
--- a/test/aaa_profiling/test_orm.py
+++ b/test/aaa_profiling/test_orm.py
@@ -310,3 +310,63 @@ class DeferOptionsTest(fixtures.MappedTest):
*[defer(letter) for letter in ['x', 'y', 'z', 'p', 'q', 'r']]).\
all()
+
+class AttributeOverheadTest(fixtures.MappedTest):
+ @classmethod
+ def define_tables(cls, metadata):
+ Table('parent', metadata, Column('id', Integer,
+ primary_key=True,
+ test_needs_autoincrement=True), Column('data',
+ String(20)))
+ Table('child', metadata, Column('id', Integer,
+ primary_key=True, test_needs_autoincrement=True),
+ Column('data', String(20)), Column('parent_id',
+ Integer, ForeignKey('parent.id'), nullable=False))
+
+ @classmethod
+ def setup_classes(cls):
+ class Parent(cls.Basic):
+ pass
+
+ class Child(cls.Basic):
+ pass
+
+ @classmethod
+ def setup_mappers(cls):
+ Child, Parent, parent, child = (cls.classes.Child,
+ cls.classes.Parent,
+ cls.tables.parent,
+ cls.tables.child)
+
+ mapper(Parent, parent, properties={'children':
+ relationship(Child, backref='parent')})
+ mapper(Child, child)
+
+
+ def test_attribute_set(self):
+ Parent, Child = self.classes.Parent, self.classes.Child
+ p1 = Parent()
+ c1 = Child()
+
+ @profiling.function_call_count()
+ def go():
+ for i in range(30):
+ c1.parent = p1
+ c1.parent = None
+ c1.parent = p1
+ del c1.parent
+ go()
+
+ def test_collection_append_remove(self):
+ Parent, Child = self.classes.Parent, self.classes.Child
+ p1 = Parent()
+ children = [Child() for i in range(100)]
+
+ @profiling.function_call_count()
+ def go():
+ for child in children:
+ p1.children.append(child)
+ for child in children:
+ p1.children.remove(child)
+ go()
+