summaryrefslogtreecommitdiffstats
path: root/pgcli/main.py
diff options
context:
space:
mode:
authorIrina Truong <i.chernyavska@gmail.com>2018-12-01 18:23:50 -0800
committerIrina Truong <i.chernyavska@gmail.com>2018-12-01 18:23:50 -0800
commit679d7939bb1c983eecd1c1469142b95e0fcc4ae7 (patch)
treee0c7fde9b154bd521c15638d4d39fcb0f91ca365 /pgcli/main.py
parent7b03f8e2043682aa2d1c06e0f7e8258b2f9c43c5 (diff)
Time execution separately.
Diffstat (limited to 'pgcli/main.py')
-rw-r--r--pgcli/main.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/pgcli/main.py b/pgcli/main.py
index bb80e787..6a900651 100644
--- a/pgcli/main.py
+++ b/pgcli/main.py
@@ -87,14 +87,15 @@ MetaQuery = namedtuple(
[
'query', # The entire text of the command
'successful', # True If all subqueries were successful
- 'total_time', # Time elapsed executing the query
+ 'total_time', # Time elapsed executing the query and formatting results
+ 'execution_time', # Time elapsed executing the query
'meta_changed', # True if any subquery executed create/alter/drop
'db_changed', # True if any subquery changed the database
'path_changed', # True if any subquery changed the search path
'mutated', # True if any subquery executed insert/update/delete
'is_special', # True if the query is a special command
])
-MetaQuery.__new__.__defaults__ = ('', False, 0, False, False, False, False)
+MetaQuery.__new__.__defaults__ = ('', False, 0, 0, False, False, False, False)
OutputSettings = namedtuple(
'OutputSettings',
@@ -591,8 +592,10 @@ class PGCli(object):
if self.pgspecial.timing_enabled:
# Only add humanized time display if > 1 second
if query.total_time > 1:
- print('Time: %0.03fs (%s)' % (query.total_time,
- humanize.time.naturaldelta(query.total_time)))
+ print('Time: %0.03fs (%s), executed in: %0.03fs (%s)' % (query.total_time,
+ humanize.time.naturaldelta(query.total_time),
+ query.execution_time,
+ humanize.time.naturaldelta(query.execution_time)))
else:
print('Time: %0.03fs' % query.total_time)
@@ -757,6 +760,7 @@ class PGCli(object):
path_changed = False
output = []
total = 0
+ execution = 0
# Run the query.
start = time()
@@ -795,6 +799,7 @@ class PGCli(object):
),
style_output=self.style_output
)
+ execution = time() - start
formatted = format_output(title, cur, headers, status, settings)
output.extend(formatted)
@@ -810,7 +815,7 @@ class PGCli(object):
else:
all_success = False
- meta_query = MetaQuery(text, all_success, total, meta_changed,
+ meta_query = MetaQuery(text, all_success, total, execution, meta_changed,
db_changed, path_changed, mutated, is_special)
return output, meta_query