diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-13 21:16:08 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-13 21:16:08 +0000 |
| commit | aedcd6aea6aa3b4601bbc26f5fc23c084c8996ac (patch) | |
| tree | bcf773463439c124b0ea8c655e3ac461c26686b5 /test/perf/objselectspeed.py | |
| parent | f4573f73d0c7f7ce5b184e6c227d0e4f406643a5 (diff) | |
| download | sqlalchemy-aedcd6aea6aa3b4601bbc26f5fc23c084c8996ac.tar.gz | |
- reduced a bit of overhead in attribute expiration, particularly
the version called by column loaders on an incomplete row (i.e.
joined table inheritance). there are more dramatic changes
that can be made here but this one is conservative so far
as far as how much we're altering how InstanceState tracks
"expired" attributes.
Diffstat (limited to 'test/perf/objselectspeed.py')
| -rw-r--r-- | test/perf/objselectspeed.py | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/test/perf/objselectspeed.py b/test/perf/objselectspeed.py index e04ef4efb..d3fd34046 100644 --- a/test/perf/objselectspeed.py +++ b/test/perf/objselectspeed.py @@ -8,21 +8,44 @@ db = create_engine('sqlite://') metadata = MetaData(db) Person_table = Table('Person', metadata, Column('id', Integer, primary_key=True), + Column('type', String(10)), Column('name', String(40)), Column('sex', Integer), Column('age', Integer)) + +Employee_table = Table('Employee', metadata, + Column('id', Integer, ForeignKey('Person.id'), primary_key=True), + Column('foo', String(40)), + Column('bar', Integer), + Column('bat', Integer)) + class RawPerson(object): pass class Person(object): pass mapper(Person, Person_table) + +class JoinedPerson(object):pass +class Employee(JoinedPerson):pass +mapper(JoinedPerson, Person_table, \ + polymorphic_on=Person_table.c.type, polymorphic_identity='person') +mapper(Employee, Employee_table, \ + inherits=JoinedPerson, polymorphic_identity='employee') compile_mappers() def setup(): metadata.create_all() i = Person_table.insert() - data = [{'name':'John Doe','sex':1,'age':35}] * 100 + data = [{'name':'John Doe','sex':1,'age':35, 'type':'employee'}] * 100 for j in xrange(500): i.execute(data) + + # note we arent fetching from employee_table, + # so we can leave it empty even though its "incorrect" + #i = Employee_table.insert() + #data = [{'foo':'foo', 'bar':'bar':'bat':'bat'}] * 100 + #for j in xrange(500): + # i.execute(data) + print "Inserted 50,000 rows" def sqlite_select(entity_cls): @@ -55,6 +78,11 @@ def orm_select(): session = create_session() people = session.query(Person).all() +#@profiling.profiled(report=True, always=True) +def joined_orm_select(): + session = create_session() + people = session.query(JoinedPerson).all() + def all(): setup() try: @@ -103,6 +131,13 @@ def all(): orm_select() t2 = time.clock() usage('sqlalchemy.orm fetch') + + gc_collect() + usage.snap() + t = time.clock() + joined_orm_select() + t2 = time.clock() + usage('sqlalchemy.orm "joined" fetch') finally: metadata.drop_all() |
