diff options
author | Jason Kirtland <jek@discorporate.us> | 2008-01-12 22:03:42 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2008-01-12 22:03:42 +0000 |
commit | 17d3c8764e020379e54053bca0b0a2bc71d48aa0 (patch) | |
tree | 0b46f1ddc57292b8f5bfbc28ab1679230f63e426 /test/perf/insertspeed.py | |
parent | c194962019d1bc7322e20b82c33aa1bab3bc2a28 (diff) | |
download | sqlalchemy-17d3c8764e020379e54053bca0b0a2bc71d48aa0.tar.gz |
- testbase is gone, replaced by testenv
- Importing testenv has no side effects- explicit functions provide similar behavior to the old immediate behavior of testbase
- testing.db has the configured db
- Fixed up the perf/* scripts
Diffstat (limited to 'test/perf/insertspeed.py')
-rw-r--r-- | test/perf/insertspeed.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/test/perf/insertspeed.py b/test/perf/insertspeed.py index cb6a9bf34..32877560e 100644 --- a/test/perf/insertspeed.py +++ b/test/perf/insertspeed.py @@ -1,8 +1,8 @@ -import testbase +import testenv; testenv.simple_setup() import sys, time from sqlalchemy import * from sqlalchemy.orm import * -from testlib import * +from testlib import profiling db = create_engine('sqlite://') metadata = MetaData(db) @@ -21,7 +21,7 @@ def sqlite_unprofiled_insertmany(n): c = conn.cursor() persons = [('john doe', 1, 35) for i in xrange(n)] c.executemany("insert into Person(name, sex, age) values (?,?,?)", persons) - + @profiling.profiled('sa_profiled_insert_many', always=True) def sa_profiled_insert_many(n): i = Person_table.insert() @@ -35,7 +35,7 @@ def sqlite_unprofiled_insert(n): c = conn.cursor() for j in xrange(n): c.execute("insert into Person(name, sex, age) values (?,?,?)", - ('john doe', 1, 35)) + ('john doe', 1, 35)) def sa_unprofiled_insert(n): # Another option is to build Person_table.insert() outside of the @@ -59,7 +59,7 @@ def run_timed(fn, label, *args, **kw): sys.stdout.write("%s (%s): " % (label, ', '.join([str(a) for a in args]))) sys.stdout.flush() - + t = time.clock() fn(*args, **kw) t2 = time.clock() @@ -80,7 +80,7 @@ def all(): run_timed(sqlite_unprofiled_insertmany, 'pysqlite bulk insert', 50000) - + run_timed(sa_unprofiled_insertmany, 'SQLAlchemy bulk insert', 50000) @@ -102,7 +102,7 @@ def all(): run_profiled(sa_profiled_insert, 'SQLAlchemy individual insert/select, profiled', 1000) - + finally: metadata.drop_all() |