From 6420da0d6e1a05ebdda319e626bec9a82bd90c84 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 23 Jan 2015 00:01:29 +0530 Subject: [PATCH] Only print timing info in debug mode --- src/calibre/gui2/tweak_book/reports.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/tweak_book/reports.py b/src/calibre/gui2/tweak_book/reports.py index d43ed062a3..a88ae20efc 100644 --- a/src/calibre/gui2/tweak_book/reports.py +++ b/src/calibre/gui2/tweak_book/reports.py @@ -6,6 +6,7 @@ from __future__ import (unicode_literals, division, absolute_import, __license__ = 'GPL v3' __copyright__ = '2015, Kovid Goyal ' +import time from threading import Thread from future_builtins import map from operator import itemgetter @@ -24,6 +25,7 @@ from PyQt5.Qt import ( QFontDatabase, QComboBox) from calibre import human_readable, fit_image +from calibre.constants import DEBUG from calibre.ebooks.oeb.polish.report import gather_data, CSSEntry, CSSFileMatch, MatchLocation from calibre.gui2 import error_dialog, question_dialog, choose_save_file from calibre.gui2.tweak_book import current_container, tprefs, dictionaries @@ -944,7 +946,11 @@ class ReportsWidget(QWidget): def __call__(self, data): jump.clear() for i in xrange(self.stack.count()): + st = time.time() self.stack.widget(i)(data) + if DEBUG: + category = self.reports.item(i).data(Qt.DisplayRole) + print ('Widget time for %12s: %.2fs seconds' % (category, time.time() - st)) def save(self): save_state('splitter-state', bytearray(self.splitter.saveState())) @@ -1042,11 +1048,9 @@ class Reports(Dialog): 'Failed to gather data for the report. Click "Show details" for more' ' information.'), det_msg=data, show=True) data, timing = data - try: + if DEBUG: for x, t in sorted(timing.iteritems(), key=itemgetter(1)): print ('Time for %6s data: %.3f seconds' % (x, t)) - except Exception: - pass self.reports(data) def accept(self):