[querier] Add timings to debug prints (DBG_RQL) stable
authorDenis Laxalde <denis.laxalde@logilab.fr>
Mon, 22 Jul 2013 12:08:37 +0200
branchstable
changeset 9180 13ed6de41774
parent 9179 570208f74a84
child 9181 2eac0aa1d3f6
[querier] Add timings to debug prints (DBG_RQL) this may ease to spot some problematic queries
server/sources/__init__.py
--- a/server/sources/__init__.py	Wed Jul 24 08:43:16 2013 +0200
+++ b/server/sources/__init__.py	Mon Jul 22 12:08:37 2013 +0200
@@ -21,6 +21,7 @@
 
 import itertools
 from os.path import join, splitext
+from time import time
 from datetime import datetime, timedelta
 from logging import getLogger
 
@@ -37,7 +38,9 @@
 
 def dbg_st_search(uri, union, varmap, args, cachekey=None, prefix='rql for'):
     if server.DEBUG & server.DBG_RQL:
+        global t
         print '  %s %s source: %s' % (prefix, uri, repr(union.as_string()))
+        t = time()
         if varmap:
             print '    using varmap', varmap
         if server.DEBUG & server.DBG_MORE:
@@ -51,9 +54,10 @@
 def dbg_results(results):
     if server.DEBUG & server.DBG_RQL:
         if len(results) > 10:
-            print '  -->', results[:10], '...', len(results)
+            print '  -->', results[:10], '...', len(results),
         else:
-            print '  -->', results
+            print '  -->', results,
+        print 'time: ', time() - t
     # return true so it can be used as assertion (and so be killed by python -O)
     return True