summaryrefslogtreecommitdiff
path: root/test/perf
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2009-08-06 21:11:27 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2009-08-06 21:11:27 +0000
commit8fc5005dfe3eb66a46470ad8a8c7b95fc4d6bdca (patch)
treeae9e27d12c9fbf8297bb90469509e1cb6a206242 /test/perf
parent7638aa7f242c6ea3d743aa9100e32be2052546a6 (diff)
downloadsqlalchemy-8fc5005dfe3eb66a46470ad8a8c7b95fc4d6bdca.tar.gz
merge 0.6 series to trunk.
Diffstat (limited to 'test/perf')
-rw-r--r--test/perf/insertspeed.py2
-rw-r--r--test/perf/masscreate.py2
-rw-r--r--test/perf/masscreate2.py4
-rw-r--r--test/perf/masseagerload.py3
-rw-r--r--test/perf/massload.py16
-rw-r--r--test/perf/masssave.py12
-rw-r--r--test/perf/objselectspeed.py13
-rw-r--r--test/perf/objupdatespeed.py11
-rw-r--r--test/perf/ormsession.py5
-rw-r--r--test/perf/poolload.py3
-rw-r--r--test/perf/sessions.py24
-rw-r--r--test/perf/wsgi.py3
12 files changed, 45 insertions, 53 deletions
diff --git a/test/perf/insertspeed.py b/test/perf/insertspeed.py
index 32877560e..0491e9f95 100644
--- a/test/perf/insertspeed.py
+++ b/test/perf/insertspeed.py
@@ -2,7 +2,7 @@ import testenv; testenv.simple_setup()
import sys, time
from sqlalchemy import *
from sqlalchemy.orm import *
-from testlib import profiling
+from sqlalchemy.test import profiling
db = create_engine('sqlite://')
metadata = MetaData(db)
diff --git a/test/perf/masscreate.py b/test/perf/masscreate.py
index ae32f83e2..5b8e0da55 100644
--- a/test/perf/masscreate.py
+++ b/test/perf/masscreate.py
@@ -3,7 +3,6 @@ import testenv; testenv.simple_setup()
from sqlalchemy.orm import attributes
import time
-import gc
manage_attributes = True
init_attributes = manage_attributes and True
@@ -34,7 +33,6 @@ for i in range(0,130):
attributes.manage(a)
a.email = 'foo@bar.com'
u.addresses.append(a)
-# gc.collect()
# print len(managed_attributes)
# managed_attributes.clear()
total = time.time() - now
diff --git a/test/perf/masscreate2.py b/test/perf/masscreate2.py
index 25d4b4915..e525fcf99 100644
--- a/test/perf/masscreate2.py
+++ b/test/perf/masscreate2.py
@@ -1,9 +1,9 @@
import testenv; testenv.simple_setup()
-import gc
import random, string
from sqlalchemy.orm import attributes
+from sqlalchemy.test.util import gc_collect
# with this test, run top. make sure the Python process doenst grow in size arbitrarily.
@@ -33,4 +33,4 @@ for i in xrange(1000):
a.user = u
print "clearing"
#managed_attributes.clear()
- gc.collect()
+ gc_collect()
diff --git a/test/perf/masseagerload.py b/test/perf/masseagerload.py
index a848b866c..88a3ade20 100644
--- a/test/perf/masseagerload.py
+++ b/test/perf/masseagerload.py
@@ -1,7 +1,6 @@
-import testenv; testenv.configure_for_tests()
from sqlalchemy import *
from sqlalchemy.orm import *
-from testlib import *
+from sqlalchemy.test import *
NUM = 500
DIVISOR = 50
diff --git a/test/perf/massload.py b/test/perf/massload.py
index 9391ead2a..f6cde3adf 100644
--- a/test/perf/massload.py
+++ b/test/perf/massload.py
@@ -1,10 +1,8 @@
-import testenv; testenv.configure_for_tests()
import time
-#import gc
#import sqlalchemy.orm.attributes as attributes
from sqlalchemy import *
from sqlalchemy.orm import *
-from testlib import *
+from sqlalchemy.test import *
"""
@@ -18,16 +16,18 @@ top while it runs
NUM = 2500
class LoadTest(TestBase, AssertsExecutionResults):
- def setUpAll(self):
+ @classmethod
+ def setup_class(cls):
global items, meta
meta = MetaData(testing.db)
items = Table('items', meta,
Column('item_id', Integer, primary_key=True),
Column('value', String(100)))
items.create()
- def tearDownAll(self):
+ @classmethod
+ def teardown_class(cls):
items.drop()
- def setUp(self):
+ def setup(self):
for x in range(1,NUM/500+1):
l = []
for y in range(x*500-500 + 1, x*500 + 1):
@@ -43,7 +43,7 @@ class LoadTest(TestBase, AssertsExecutionResults):
query = sess.query(Item)
for x in range (1,NUM/100):
# this is not needed with cpython which clears non-circular refs immediately
- #gc.collect()
+ #gc_collect()
l = query.filter(items.c.item_id.between(x*100 - 100 + 1, x*100)).all()
assert len(l) == 100
print "loaded ", len(l), " items "
@@ -61,5 +61,3 @@ class LoadTest(TestBase, AssertsExecutionResults):
print "total time ", total
-if __name__ == "__main__":
- testenv.main()
diff --git a/test/perf/masssave.py b/test/perf/masssave.py
index bf65c8fdf..41acd12cc 100644
--- a/test/perf/masssave.py
+++ b/test/perf/masssave.py
@@ -1,21 +1,23 @@
-import testenv; testenv.configure_for_tests()
+import gc
import types
from sqlalchemy import *
from sqlalchemy.orm import *
-from testlib import *
+from sqlalchemy.test import *
NUM = 2500
class SaveTest(TestBase, AssertsExecutionResults):
- def setUpAll(self):
+ @classmethod
+ def setup_class(cls):
global items, metadata
metadata = MetaData(testing.db)
items = Table('items', metadata,
Column('item_id', Integer, primary_key=True),
Column('value', String(100)))
items.create()
- def tearDownAll(self):
+ @classmethod
+ def teardown_class(cls):
clear_mappers()
metadata.drop_all()
@@ -50,5 +52,3 @@ class SaveTest(TestBase, AssertsExecutionResults):
print x
-if __name__ == "__main__":
- testenv.main()
diff --git a/test/perf/objselectspeed.py b/test/perf/objselectspeed.py
index 896fd4c49..867a396f3 100644
--- a/test/perf/objselectspeed.py
+++ b/test/perf/objselectspeed.py
@@ -1,7 +1,8 @@
import testenv; testenv.simple_setup()
-import time, gc, resource
+import time, resource
from sqlalchemy import *
from sqlalchemy.orm import *
+from sqlalchemy.test.util import gc_collect
db = create_engine('sqlite://')
@@ -68,35 +69,35 @@ def all():
usage.snap = lambda stats=None: setattr(
usage, 'last', stats or resource.getrusage(resource.RUSAGE_SELF))
- gc.collect()
+ gc_collect()
usage.snap()
t = time.clock()
sqlite_select(RawPerson)
t2 = time.clock()
usage('sqlite select/native')
- gc.collect()
+ gc_collect()
usage.snap()
t = time.clock()
sqlite_select(Person)
t2 = time.clock()
usage('sqlite select/instrumented')
- gc.collect()
+ gc_collect()
usage.snap()
t = time.clock()
sql_select(RawPerson)
t2 = time.clock()
usage('sqlalchemy.sql select/native')
- gc.collect()
+ gc_collect()
usage.snap()
t = time.clock()
sql_select(Person)
t2 = time.clock()
usage('sqlalchemy.sql select/instrumented')
- gc.collect()
+ gc_collect()
usage.snap()
t = time.clock()
orm_select()
diff --git a/test/perf/objupdatespeed.py b/test/perf/objupdatespeed.py
index a49eb4724..52224211a 100644
--- a/test/perf/objupdatespeed.py
+++ b/test/perf/objupdatespeed.py
@@ -1,8 +1,9 @@
-import testenv; testenv.configure_for_tests()
-import time, gc, resource
+import time, resource
from sqlalchemy import *
from sqlalchemy.orm import *
-from testlib import *
+from sqlalchemy.test import *
+from sqlalchemy.test.util import gc_collect
+
NUM = 100
@@ -72,14 +73,14 @@ def all():
session = create_session()
- gc.collect()
+ gc_collect()
usage.snap()
t = time.clock()
people = orm_select(session)
t2 = time.clock()
usage('load objects')
- gc.collect()
+ gc_collect()
usage.snap()
t = time.clock()
update_and_flush(session, people)
diff --git a/test/perf/ormsession.py b/test/perf/ormsession.py
index cdffa51a9..f9f9dee8b 100644
--- a/test/perf/ormsession.py
+++ b/test/perf/ormsession.py
@@ -1,11 +1,10 @@
-import testenv; testenv.configure_for_tests()
import time
from datetime import datetime
from sqlalchemy import *
from sqlalchemy.orm import *
-from testlib import *
-from testlib.profiling import profiled
+from sqlalchemy.test import *
+from sqlalchemy.test.profiling import profiled
class Item(object):
def __repr__(self):
diff --git a/test/perf/poolload.py b/test/perf/poolload.py
index 8d66da84f..62c66fbae 100644
--- a/test/perf/poolload.py
+++ b/test/perf/poolload.py
@@ -1,9 +1,8 @@
# load test of connection pool
-import testenv; testenv.configure_for_tests()
import thread, time
from sqlalchemy import *
import sqlalchemy.pool as pool
-from testlib import testing
+from sqlalchemy.test import testing
db = create_engine(testing.db.url, pool_timeout=30, echo_pool=True)
metadata = MetaData(db)
diff --git a/test/perf/sessions.py b/test/perf/sessions.py
index f4be1ee93..0d4cc1f01 100644
--- a/test/perf/sessions.py
+++ b/test/perf/sessions.py
@@ -1,17 +1,17 @@
-import testenv; testenv.configure_for_tests()
from sqlalchemy import *
from sqlalchemy.orm import *
-import gc
-from testlib import TestBase, AssertsExecutionResults, profiling, testing
-from orm import _fixtures
+from sqlalchemy.test.compat import gc_collect
+from sqlalchemy.test import TestBase, AssertsExecutionResults, profiling, testing
+from test.orm import _fixtures
# in this test we are specifically looking for time spent in the attributes.InstanceState.__cleanup() method.
ITERATIONS = 100
class SessionTest(TestBase, AssertsExecutionResults):
- def setUpAll(self):
+ @classmethod
+ def setup_class(cls):
global t1, t2, metadata,T1, T2
metadata = MetaData(testing.db)
t1 = Table('t1', metadata,
@@ -46,7 +46,8 @@ class SessionTest(TestBase, AssertsExecutionResults):
})
mapper(T2, t2)
- def tearDownAll(self):
+ @classmethod
+ def teardown_class(cls):
metadata.drop_all()
clear_mappers()
@@ -60,7 +61,7 @@ class SessionTest(TestBase, AssertsExecutionResults):
sess.close()
del sess
- gc.collect()
+ gc_collect()
@profiling.profiled('dirty', report=True)
def test_session_dirty(self):
@@ -74,11 +75,11 @@ class SessionTest(TestBase, AssertsExecutionResults):
t2.c2 = 'this is some modified text'
del t1s
- gc.collect()
+ gc_collect()
sess.close()
del sess
- gc.collect()
+ gc_collect()
@profiling.profiled('noclose', report=True)
def test_session_noclose(self):
@@ -89,9 +90,6 @@ class SessionTest(TestBase, AssertsExecutionResults):
t1s[index].t2s
del sess
- gc.collect()
-
+ gc_collect()
-if __name__ == '__main__':
- testenv.main()
diff --git a/test/perf/wsgi.py b/test/perf/wsgi.py
index 6fc8149bc..549c92ade 100644
--- a/test/perf/wsgi.py
+++ b/test/perf/wsgi.py
@@ -1,11 +1,10 @@
#!/usr/bin/python
"""Uses ``wsgiref``, standard in Python 2.5 and also in the cheeseshop."""
-import testenv; testenv.configure_for_tests()
from sqlalchemy import *
from sqlalchemy.orm import *
import thread
-from testlib import *
+from sqlalchemy.test import *
port = 8000