aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Hudson2008-10-07 23:09:29 -0700
committerRob Hudson2008-10-07 23:09:29 -0700
commit07407876a608a4d573dbd6ee4cee2d3798f752c5 (patch)
treef0a6118cfc6ff0ac55cb912d8dea0d0bcdf314bc
parent285a03c0d1ab0f4b6567278f1e1871e2d5c3e21d (diff)
downloaddjango-debug-toolbar-07407876a608a4d573dbd6ee4cee2d3798f752c5.tar.bz2
Fix inconsistent SQL timings. All SQL timings are milliseconds now.
-rw-r--r--debug_toolbar/panels/sql.py4
-rw-r--r--debug_toolbar/templates/debug_toolbar/panels/sql.html8
2 files changed, 6 insertions, 6 deletions
diff --git a/debug_toolbar/panels/sql.py b/debug_toolbar/panels/sql.py
index 56b83a0..fc53247 100644
--- a/debug_toolbar/panels/sql.py
+++ b/debug_toolbar/panels/sql.py
@@ -27,7 +27,7 @@ class DatabaseStatTracker(util.CursorDebugWrapper):
# We keep `sql` to maintain backwards compatibility
self.db.queries.append({
'sql': self.db.ops.last_executed_query(self.cursor, sql, params),
- 'time': stop - start,
+ 'time': (stop - start) * 1000, # convert to ms
'raw_sql': sql,
'params': _params,
'hash': sha_constructor(settings.SECRET_KEY + sql + _params).hexdigest(),
@@ -47,7 +47,7 @@ class SQLDebugPanel(DebugPanel):
self._sql_time = 0
def title(self):
- self._sql_time = sum(map(lambda q: float(q['time']) * 1000, connection.queries))
+ self._sql_time = sum(map(lambda q: float(q['time']), connection.queries))
return '%d SQL %s (%.2fms)' % (
len(connection.queries),
(len(connection.queries) == 1) and 'query' or 'queries',
diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql.html b/debug_toolbar/templates/debug_toolbar/panels/sql.html
index d35d83e..f6ff64f 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/sql.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/sql.html
@@ -10,12 +10,12 @@
<tbody>
{% for query in queries %}
<tr class="{% cycle 'odd' 'even' %}">
- <td>{{ query.time|floatformat:"4" }}</td>
+ <td>{{ query.time|floatformat:"2" }}</td>
<td>
{% if query.params %}
- <a class="remoteCall" href="/__debug__/sql_select/?sql={{ query.raw_sql|urlencode }}&params={{ query.params|urlencode }}&time={{ query.time|floatformat:"4"|urlencode }}&hash={{ query.hash }}">SELECT</a>
- <a class="remoteCall" href="/__debug__/sql_explain/?sql={{ query.raw_sql|urlencode }}&params={{ query.params|urlencode }}&time={{ query.time|floatformat:"4"|urlencode }}&hash={{ query.hash }}">EXPLAIN</a>
- <a class="remoteCall" href="/__debug__/sql_profile/?sql={{ query.raw_sql|urlencode }}&params={{ query.params|urlencode }}&time={{ query.time|floatformat:"4"|urlencode }}&hash={{ query.hash }}">PROFILE</a>
+ <a class="remoteCall" href="/__debug__/sql_select/?sql={{ query.raw_sql|urlencode }}&params={{ query.params|urlencode }}&time={{ query.time|floatformat:"2"|urlencode }}&hash={{ query.hash }}">SELECT</a>
+ <a class="remoteCall" href="/__debug__/sql_explain/?sql={{ query.raw_sql|urlencode }}&params={{ query.params|urlencode }}&time={{ query.time|floatformat:"2"|urlencode }}&hash={{ query.hash }}">EXPLAIN</a>
+ <a class="remoteCall" href="/__debug__/sql_profile/?sql={{ query.raw_sql|urlencode }}&params={{ query.params|urlencode }}&time={{ query.time|floatformat:"2"|urlencode }}&hash={{ query.hash }}">PROFILE</a>
{% endif %}
</td>
<td class="syntax">{{ query.sql|safe }}</td>