From: Mike Bayer Date: Fri, 5 Sep 2014 00:55:38 +0000 (-0400) Subject: - add a test that shows query caching. X-Git-Tag: rel_1_0_0b1~197 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2c05c36a5c5f5b4838e924b4de2280f73916c99;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - add a test that shows query caching. --- diff --git a/examples/performance/single_inserts.py b/examples/performance/single_inserts.py index 671bbbe9ca..4178ccea83 100644 --- a/examples/performance/single_inserts.py +++ b/examples/performance/single_inserts.py @@ -87,6 +87,23 @@ def test_core(n): ) +@Profiler.profile +def test_core_query_caching(n): + """Individual INSERT/COMMIT pairs using Core with query caching""" + + cache = {} + ins = Customer.__table__.insert() + for i in range(n): + with engine.begin() as conn: + conn.execution_options(compiled_cache=cache).execute( + ins, + dict( + name='customer name %d' % i, + description='customer description %d' % i + ) + ) + + @Profiler.profile def test_dbapi_raw_w_connect(n): """Individual INSERT/COMMIT pairs using a pure DBAPI connection, @@ -130,6 +147,7 @@ def _test_dbapi_raw(n, connect): conn = engine.pool._creator() cursor = conn.cursor() cursor.execute(sql, arg) + lastrowid = cursor.lastrowid conn.commit() conn.close() else: @@ -137,6 +155,7 @@ def _test_dbapi_raw(n, connect): conn = engine.raw_connection() cursor = conn.cursor() cursor.execute(sql, arg) + lastrowid = cursor.lastrowid conn.commit() conn.close()