diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-12-19 15:59:55 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-12-21 12:20:04 -0500 |
| commit | e6cd36fc51d25922f20aa203229a636f5d6daabe (patch) | |
| tree | 661a3bbeb6ee5cbbe1f8d40aae6951d8cef12b80 /test/aaa_profiling | |
| parent | b301dd2d20f2da66f4eb69527ba2642da34c630d (diff) | |
| download | sqlalchemy-e6cd36fc51d25922f20aa203229a636f5d6daabe.tar.gz | |
implement cython for cache_anon_map, prefix_anon_map
These are small bits where cache_anon_map in particular
is part of the cache key generation scheme which is a key
target for cython.
changing such a tiny element of the cache key gen is
doing basically nothing yet, as the cython impl is
mostly the exact same speed as the python one. I guess for
cython to be effective we'd need to redo the whole cache key
generation and possibly not use the same kinds of structures,
which might not be very easy to do.
Additionally, some cython runtime import errors are being
observed on jenkins, add an upfront check to the test suite
to indicate if the expected build succeeded when REQUIRE_SQLALCHEMY_CEXT
is set.
Running case CacheAnonMap
Running python .... Done
Running cython .... Done
| python | cython | cy / py |
test_get_anon_non_present| 0.301266758 | 0.231203834 | 0.767438915 |
test_get_anon_present| 0.300919362 | 0.227336695 | 0.755473803 |
test_has_key_non_present| 0.152725077 | 0.133191719 | 0.872101171 |
test_has_key_present| 0.152689778 | 0.133673095 | 0.875455428 |
Running case PrefixAnonMap
Running python .. Done
Running cython .. Done
| python | cython | cy / py |
test_apply_non_present| 0.358715744 | 0.335245703 | 0.934572034 |
test_apply_present | 0.354434996 | 0.338579782 | 0.955266229 |
Change-Id: I0d3f1dd285c044afc234479141d831b2ee0455be
Diffstat (limited to 'test/aaa_profiling')
| -rw-r--r-- | test/aaa_profiling/test_misc.py | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/test/aaa_profiling/test_misc.py b/test/aaa_profiling/test_misc.py index 4f811e69a..c0508a3cf 100644 --- a/test/aaa_profiling/test_misc.py +++ b/test/aaa_profiling/test_misc.py @@ -90,14 +90,14 @@ class CacheKeyTest(fixtures.TestBase): ) registry.map_imperatively(Child, child) + registry.configure() + yield Parent, Child registry.dispose() @testing.fixture(scope="function") def stmt_fixture_one(self, mapping_fixture): - # note that by using ORM elements we will have annotations in these - # items also which is part of the performance hit Parent, Child = mapping_fixture return [ @@ -120,13 +120,29 @@ class CacheKeyTest(fixtures.TestBase): else: current_key = key - @profiling.function_call_count(variance=0.15, warmup=0) - def test_statement_key_is_not_cached(self, stmt_fixture_one): - current_key = None - for stmt in stmt_fixture_one: - key = stmt._generate_cache_key() - assert key is not None - if current_key: - eq_(key, current_key) - else: - current_key = key + def test_statement_key_is_not_cached( + self, stmt_fixture_one, mapping_fixture + ): + Parent, Child = mapping_fixture + + # run a totally different statement so that everything cache + # related not specific to the statement is warmed up + some_other_statement = ( + select(Parent.id, Child.id) + .join_from(Parent, Child, Parent.children) + .where(Parent.id == 5) + ) + some_other_statement._generate_cache_key() + + @profiling.function_call_count(variance=0.15, warmup=0) + def go(): + current_key = None + for stmt in stmt_fixture_one: + key = stmt._generate_cache_key() + assert key is not None + if current_key: + eq_(key, current_key) + else: + current_key = key + + go() |
