53 return self.text(column) < other.text(column) |
53 return self.text(column) < other.text(column) |
54 |
54 |
55 |
55 |
56 class PyProfileDialog(QDialog, Ui_PyProfileDialog): |
56 class PyProfileDialog(QDialog, Ui_PyProfileDialog): |
57 """ |
57 """ |
58 Class implementing a dialog to display the results of a syntax check run. |
58 Class implementing a dialog to display the results of a profiling run. |
59 """ |
59 """ |
60 def __init__(self, parent=None): |
60 def __init__(self, parent=None): |
61 """ |
61 """ |
62 Constructor |
62 Constructor |
63 |
63 |
80 self.resultList.headerItem().setText(self.resultList.columnCount(), "") |
80 self.resultList.headerItem().setText(self.resultList.columnCount(), "") |
81 self.resultList.header().setSortIndicator(0, Qt.DescendingOrder) |
81 self.resultList.header().setSortIndicator(0, Qt.DescendingOrder) |
82 |
82 |
83 self.__menu = QMenu(self) |
83 self.__menu = QMenu(self) |
84 self.filterItm = self.__menu.addAction( |
84 self.filterItm = self.__menu.addAction( |
85 self.trUtf8('Exclude Python Library'), |
85 self.tr('Exclude Python Library'), |
86 self.__filter) |
86 self.__filter) |
87 self.__menu.addSeparator() |
87 self.__menu.addSeparator() |
88 self.__menu.addAction( |
88 self.__menu.addAction( |
89 self.trUtf8('Erase Profiling Info'), self.__eraseProfile) |
89 self.tr('Erase Profiling Info'), self.__eraseProfile) |
90 self.__menu.addAction( |
90 self.__menu.addAction( |
91 self.trUtf8('Erase Timing Info'), self.__eraseTiming) |
91 self.tr('Erase Timing Info'), self.__eraseTiming) |
92 self.__menu.addSeparator() |
92 self.__menu.addSeparator() |
93 self.__menu.addAction(self.trUtf8('Erase All Infos'), self.__eraseAll) |
93 self.__menu.addAction(self.tr('Erase All Infos'), self.__eraseAll) |
94 self.resultList.setContextMenuPolicy(Qt.CustomContextMenu) |
94 self.resultList.setContextMenuPolicy(Qt.CustomContextMenu) |
95 self.resultList.customContextMenuRequested.connect( |
95 self.resultList.customContextMenuRequested.connect( |
96 self.__showContextMenu) |
96 self.__showContextMenu) |
97 self.summaryList.setContextMenuPolicy(Qt.CustomContextMenu) |
97 self.summaryList.setContextMenuPolicy(Qt.CustomContextMenu) |
98 self.summaryList.customContextMenuRequested.connect( |
98 self.summaryList.customContextMenuRequested.connect( |
208 self.resultList.setSortingEnabled(True) |
208 self.resultList.setSortingEnabled(True) |
209 self.resultList.setUpdatesEnabled(True) |
209 self.resultList.setUpdatesEnabled(True) |
210 self.__resortResultList() |
210 self.__resortResultList() |
211 |
211 |
212 # now do the summary stuff |
212 # now do the summary stuff |
213 self.__createSummaryItem(self.trUtf8("function calls"), |
213 self.__createSummaryItem(self.tr("function calls"), |
214 str(total_calls)) |
214 str(total_calls)) |
215 if total_calls != prim_calls: |
215 if total_calls != prim_calls: |
216 self.__createSummaryItem(self.trUtf8("primitive calls"), |
216 self.__createSummaryItem(self.tr("primitive calls"), |
217 str(prim_calls)) |
217 str(prim_calls)) |
218 self.__createSummaryItem(self.trUtf8("CPU seconds"), |
218 self.__createSummaryItem(self.tr("CPU seconds"), |
219 "{0:.3f}".format(total_tt)) |
219 "{0:.3f}".format(total_tt)) |
220 |
220 |
221 def start(self, pfn, fn=None): |
221 def start(self, pfn, fn=None): |
222 """ |
222 """ |
223 Public slot to start the calculation of the profile data. |
223 Public slot to start the calculation of the profile data. |
229 |
229 |
230 fname = "{0}.profile".format(self.basename) |
230 fname = "{0}.profile".format(self.basename) |
231 if not os.path.exists(fname): |
231 if not os.path.exists(fname): |
232 E5MessageBox.warning( |
232 E5MessageBox.warning( |
233 self, |
233 self, |
234 self.trUtf8("Profile Results"), |
234 self.tr("Profile Results"), |
235 self.trUtf8("""<p>There is no profiling data""" |
235 self.tr("""<p>There is no profiling data""" |
236 """ available for <b>{0}</b>.</p>""") |
236 """ available for <b>{0}</b>.</p>""") |
237 .format(pfn)) |
237 .format(pfn)) |
238 self.close() |
238 self.close() |
239 return |
239 return |
240 try: |
240 try: |
241 f = open(fname, 'rb') |
241 f = open(fname, 'rb') |
242 self.stats = pickle.load(f) |
242 self.stats = pickle.load(f) |
243 f.close() |
243 f.close() |
244 except (EnvironmentError, pickle.PickleError, EOFError): |
244 except (EnvironmentError, pickle.PickleError, EOFError): |
245 E5MessageBox.critical( |
245 E5MessageBox.critical( |
246 self, |
246 self, |
247 self.trUtf8("Loading Profiling Data"), |
247 self.tr("Loading Profiling Data"), |
248 self.trUtf8("""<p>The profiling data could not be""" |
248 self.tr("""<p>The profiling data could not be""" |
249 """ read from file <b>{0}</b>.</p>""") |
249 """ read from file <b>{0}</b>.</p>""") |
250 .format(fname)) |
250 .format(fname)) |
251 self.close() |
251 self.close() |
252 return |
252 return |
253 |
253 |
254 self.file = fn |
254 self.file = fn |