diff options
| author | Aymeric Augustin | 2013-10-17 20:48:50 +0200 |
|---|---|---|
| committer | Aymeric Augustin | 2013-10-17 20:49:29 +0200 |
| commit | 80dd45632aa21c667e841a1131c74e79d1518881 (patch) | |
| tree | 9bfb22a6029f4c16592eb0df8e9912174aa56a19 /debug_toolbar/management/commands/debugsqlshell.py | |
| parent | 59c6e0933d04ddecf6727d8e8671fc6ebf4ccfc7 (diff) | |
| download | django-debug-toolbar-80dd45632aa21c667e841a1131c74e79d1518881.tar.bz2 | |
Simplify timing implementation.
Diffstat (limited to 'debug_toolbar/management/commands/debugsqlshell.py')
| -rw-r--r-- | debug_toolbar/management/commands/debugsqlshell.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/debug_toolbar/management/commands/debugsqlshell.py b/debug_toolbar/management/commands/debugsqlshell.py index e94e4e2..c5718b8 100644 --- a/debug_toolbar/management/commands/debugsqlshell.py +++ b/debug_toolbar/management/commands/debugsqlshell.py @@ -1,24 +1,23 @@ from __future__ import print_function, unicode_literals -from datetime import datetime +from time import time from django.db.backends import util import sqlparse -from debug_toolbar.utils import ms_from_timedelta - class PrintQueryWrapper(util.CursorDebugWrapper): def execute(self, sql, params=()): - starttime = datetime.now() + start_time = time() try: return self.cursor.execute(sql, params) finally: raw_sql = self.db.ops.last_executed_query(self.cursor, sql, params) - execution_time = ms_from_timedelta(datetime.now() - starttime) + end_time = time() + duration = (end_time - start_time) * 1000 formatted_sql = sqlparse.format(raw_sql, reindent=True) - print('%s [%.2fms]' % (formatted_sql, execution_time)) + print('%s [%.2fms]' % (formatted_sql, duration)) util.CursorDebugWrapper = PrintQueryWrapper |
