Project

General

Profile

« Previous | Next » 

Revision 3242

sql.py: DbConn.run_query(): Only profile queries in debug mode, to avoid unnecessary overhead when the run time will not be displayed

View differences:

lib/sql.py
355 355
        if not self.caching: cacheable = False
356 356
        used_cache = False
357 357
        
358
        profiler = profiling.ItersProfiler(start_now=True, iter_text='row')
358
        if self.debug:
359
            profiler = profiling.ItersProfiler(start_now=True, iter_text='row')
359 360
        try:
360 361
            # Get cursor
361 362
            if cacheable:
......
371 372
                raise
372 373
            else: self.do_autocommit()
373 374
        finally:
374
            profiler.stop()
375
            self.print_notices()
376
            if self.debug: # log or return query
375
            if self.debug:
376
                profiler.stop()
377
                
378
                ## Log or return query
379
                
377 380
                query = str(get_cur_query(cur, query))
378 381
                # So that the src comment is hidden when cating the file, and
379 382
                # put on a separate line when viewed in a text editor.
......
389 392
                
390 393
                if debug_msg_ref != None: debug_msg_ref[0] = msg
391 394
                else: self.log_debug(msg, log_level)
395
            self.print_notices()
392 396
        
393 397
        return cur
394 398
    

Also available in: Unified diff