mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Add timer to LoggingTransaction
This commit is contained in:
parent
c372929ab6
commit
8e358ef35a
@ -23,6 +23,7 @@ from synapse.util.logutils import log_function
|
|||||||
import collections
|
import collections
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -61,9 +62,15 @@ class LoggingTransaction(object):
|
|||||||
|
|
||||||
# TODO(paul): Here would be an excellent place to put some timing
|
# TODO(paul): Here would be an excellent place to put some timing
|
||||||
# measurements, and log (warning?) slow queries.
|
# 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):
|
class SQLBaseStore(object):
|
||||||
|
Loading…
Reference in New Issue
Block a user