summary refs log tree commit diff
path: root/synapse/storage/_base.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-10-28 10:34:05 +0000
committerErik Johnston <erik@matrix.org>2014-10-28 10:34:05 +0000
commit8e358ef35a8e2640176003cdb2396a9b4d71fbce (patch)
tree0868d29d3ec2c489499cf3ceb625a66a31f5a3b7 /synapse/storage/_base.py
parentRemove duplicate import (diff)
downloadsynapse-8e358ef35a8e2640176003cdb2396a9b4d71fbce.tar.xz
Add timer to LoggingTransaction
Diffstat (limited to 'synapse/storage/_base.py')
-rw-r--r--synapse/storage/_base.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index 65a86e9056..e839704a8c 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -23,6 +23,7 @@ from synapse.util.logutils import log_function
 import collections
 import copy
 import json
+import time
 
 
 logger = logging.getLogger(__name__)
@@ -61,9 +62,15 @@ class LoggingTransaction(object):
 
         # TODO(paul): Here would be an excellent place to put some timing
         #   measurements, and log (warning?) slow queries.
-        return object.__getattribute__(self, "txn").execute(
-            sql, *args, **kwargs
-        )
+
+        start = time.clock() * 1000
+        try:
+            return object.__getattribute__(self, "txn").execute(
+                sql, *args, **kwargs
+            )
+        finally:
+            end = time.clock() * 1000
+            sql_logger.debug("[SQL time] %f", end - start)
 
 
 class SQLBaseStore(object):