]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Add profile sort option to test suite
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 14 Jul 2019 15:43:29 +0000 (11:43 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 14 Jul 2019 15:43:29 +0000 (11:43 -0400)
I use the nfl sort a lot to see what calling changes are happening
between two versions in order to identify the offending code, so
add it as a command line option.

Change-Id: Ia1ab6dd98012a78298b325bb5c7c050fa9b767c2

lib/sqlalchemy/testing/plugin/plugin_base.py
lib/sqlalchemy/testing/profiling.py

index 4593f1431470ffd7bb654921c86cc69fed2bfb51..859d1d7799c2c64fbce1d68d3749b1624ada4600 100644 (file)
@@ -101,6 +101,13 @@ def setup_options(make_option):
         dest="nomemory",
         help="Don't run memory profiling tests",
     )
+    make_option(
+        "--profile-sort",
+        type="string",
+        default="cumulative",
+        dest="profilesort",
+        help="Type of sort for profiling standard output",
+    )
     make_option(
         "--postgresql-templatedb",
         type="string",
@@ -474,7 +481,8 @@ def _setup_profiling(options, file_config):
     from sqlalchemy.testing import profiling
 
     profiling._profile_stats = profiling.ProfileStatsFile(
-        file_config.get("sqla_testing", "profile_file")
+        file_config.get("sqla_testing", "profile_file"),
+        sort=options.profilesort,
     )
 
 
index a75549027e206ae31ab0d75c2440b8bd06ac738a..bfc4997e132cc2e61235a82fb7ab49839dc82f7e 100644 (file)
@@ -65,7 +65,7 @@ class ProfileStatsFile(object):
 
     """
 
-    def __init__(self, filename):
+    def __init__(self, filename, sort="cumulative"):
         self.force_write = (
             config.options is not None and config.options.force_write_profiles
         )
@@ -77,6 +77,7 @@ class ProfileStatsFile(object):
         self.data = collections.defaultdict(
             lambda: collections.defaultdict(dict)
         )
+        self.sort = sort
         self._read()
         if self.write:
             # rewrite for the case where features changed,
@@ -277,7 +278,7 @@ def count_functions(variance=0.05):
         line_no, expected_count = expected
 
     print(("Pstats calls: %d Expected %s" % (callcount, expected_count)))
-    stats.sort_stats("cumulative")
+    stats.sort_stats(_profile_stats.sort)
     stats.print_stats()
 
     if _profile_stats.force_write: