(runsnake=False, dump=False)
| 121 | |
| 122 | |
| 123 | def run_with_profile(runsnake=False, dump=False): |
| 124 | import cProfile |
| 125 | import pstats |
| 126 | |
| 127 | filename = "orm2010.profile" |
| 128 | |
| 129 | if os.path.exists("orm2010.profile"): |
| 130 | os.remove("orm2010.profile") |
| 131 | |
| 132 | def status(msg): |
| 133 | print(msg) |
| 134 | |
| 135 | cProfile.runctx( |
| 136 | # "runit_persist(status)", |
| 137 | "runit_persist(status); runit_query_runs(status)", |
| 138 | globals(), |
| 139 | locals(), |
| 140 | filename, |
| 141 | ) |
| 142 | stats = pstats.Stats(filename) |
| 143 | |
| 144 | counts_by_methname = {key[2]: stats.stats[key][0] for key in stats.stats} |
| 145 | |
| 146 | print("SQLA Version: %s" % __version__) |
| 147 | print("Total calls %d" % stats.total_calls) |
| 148 | print("Total cpu seconds: %.2f" % stats.total_tt) |
| 149 | print( |
| 150 | "Total execute calls: %d" |
| 151 | % counts_by_methname["<method 'execute' of 'sqlite3.Cursor' objects>"] |
| 152 | ) |
| 153 | print( |
| 154 | "Total executemany calls: %d" |
| 155 | % counts_by_methname.get( |
| 156 | "<method 'executemany' of 'sqlite3.Cursor' objects>", 0 |
| 157 | ) |
| 158 | ) |
| 159 | |
| 160 | if dump: |
| 161 | # stats.sort_stats("nfl") |
| 162 | stats.sort_stats("cumtime", "calls") |
| 163 | stats.print_stats() |
| 164 | # stats.print_callers() |
| 165 | |
| 166 | if runsnake: |
| 167 | os.system("runsnake %s" % filename) |
| 168 | |
| 169 | |
| 170 | def run_with_time(factor): |
no test coverage detected