Revision 3241
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
9 | 9 |
import dicts |
10 | 10 |
import iters |
11 | 11 |
import lists |
12 |
import profiling |
|
12 | 13 |
from Proxy import Proxy |
13 | 14 |
import rand |
14 | 15 |
import sql_gen |
... | ... | |
354 | 355 |
if not self.caching: cacheable = False |
355 | 356 |
used_cache = False |
356 | 357 |
|
357 |
start_time = time.time()
|
|
358 |
profiler = profiling.ItersProfiler(start_now=True, iter_text='row')
|
|
358 | 359 |
try: |
359 | 360 |
# Get cursor |
360 | 361 |
if cacheable: |
... | ... | |
370 | 371 |
raise |
371 | 372 |
else: self.do_autocommit() |
372 | 373 |
finally: |
373 |
time_ = time.time() - start_time
|
|
374 |
profiler.stop()
|
|
374 | 375 |
self.print_notices() |
375 | 376 |
if self.debug: # log or return query |
376 | 377 |
query = str(get_cur_query(cur, query)) |
... | ... | |
384 | 385 |
elif cacheable: msg += 'cache miss' |
385 | 386 |
else: msg += 'non-cacheable' |
386 | 387 |
|
387 |
msg += ', took '+str(time_)+'s:\n'+strings.as_code(query, 'SQL')
|
|
388 |
msg += ':\n'+profiler.msg()+'\n'+strings.as_code(query, 'SQL')
|
|
388 | 389 |
|
389 | 390 |
if debug_msg_ref != None: debug_msg_ref[0] = msg |
390 | 391 |
else: self.log_debug(msg, log_level) |
Also available in: Unified diff
sql.py: DbConn.run_query(): Profile using the profiling.ItersProfiler class, which pretty-prints the run time