Skip to content

Commit 766fb8d

Browse files
committed
Showing curves/plots number in benchmarks to avoid any misinterpretation (see Issue #26)
1 parent fd8ec23 commit 766fb8d

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

qwt/tests/CurveBenchmark.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ def __init__(self, title, xdata, ydata, style, symbol=None, *args):
4545
self.setTitle(title)
4646
self.setAxisTitle(QwtPlot.xBottom, 'x')
4747
self.setAxisTitle(QwtPlot.yLeft, 'y')
48+
self.curve_nb = 0
4849
for idx in range(1, 11):
50+
self.curve_nb += 1
4951
curve = QwtPlotCurve()
5052
curve.setPen(QPen(get_curve_color()))
5153
curve.setStyle(style)
@@ -62,6 +64,8 @@ def __init__(self, title, xdata, ydata, style, symbol=None, *args):
6264
class BMWidget(QWidget):
6365
def __init__(self, points, *args, **kwargs):
6466
super(BMWidget, self).__init__()
67+
self.plot_nb = 0
68+
self.curve_nb = 0
6569
self.setup(points, *args, **kwargs)
6670

6771
def params(self, *args, **kwargs):
@@ -79,8 +83,11 @@ def setup(self, points, *args, **kwargs):
7983
layout = QGridLayout()
8084
nbcol, col, row = 2, 0, 0
8185
for style, symbol in self.params(*args, **kwargs):
82-
layout.addWidget(BMPlot(style, x, y, getattr(QwtPlotCurve, style),
83-
symbol=symbol), row, col)
86+
plot = BMPlot(style, x, y, getattr(QwtPlotCurve, style),
87+
symbol=symbol)
88+
layout.addWidget(plot, row, col)
89+
self.plot_nb += 1
90+
self.curve_nb += plot.curve_nb
8491
col += 1
8592
if col >= nbcol:
8693
row +=1
@@ -139,7 +146,7 @@ def __init__(self, max_n, parent=None, **kwargs):
139146
self.text.append("<br><br><u>Total elapsed time</u>: %d ms" % (dt*1e3))
140147
self.tabs.setCurrentIndex(0)
141148

142-
def process_iteration(self, title, widget, t0):
149+
def process_iteration(self, title, description, widget, t0):
143150
self.tabs.addTab(widget, title)
144151
self.tabs.setCurrentWidget(widget)
145152

@@ -148,15 +155,17 @@ def process_iteration(self, title, widget, t0):
148155

149156
time_str = "Elapsed time: %d ms" % ((time.time()-t0)*1000)
150157
widget.text.setText(time_str)
151-
self.text.append("<br><i>%s:</i><br>%s" % (title, time_str))
158+
self.text.append("<br><i>%s:</i><br>%s" % (description, time_str))
152159

153160
def run_benchmark(self, max_n, **kwargs):
154161
for idx in range(4, -1, -1):
155162
points = max_n/10**idx
156-
title = '%d points' % points
157163
t0 = time.time()
158164
widget = BMWidget(points, **kwargs)
159-
self.process_iteration(title, widget, t0)
165+
title = '%d points' % points
166+
description = '%d plots with %d curves of %d points' % (
167+
widget.plot_nb, widget.curve_nb, points)
168+
self.process_iteration(title, description, widget, t0)
160169

161170

162171
if __name__ == '__main__':

qwt/tests/CurveStyles.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ def run_benchmark(self, max_n, **kwargs):
5555
(True, False)*2):
5656
t0 = time.time()
5757
symtext = "with%s symbols" % ("" if symbols else "out")
58-
title = '%d points, %s' % (points, symtext)
5958
widget = CSWidget(points, symbols, **kwargs)
60-
self.process_iteration(title, widget, t0)
59+
title = '%d points' % points
60+
description = '%d plots with %d curves of %d points, %s' % (
61+
widget.plot_nb, widget.curve_nb, points, symtext)
62+
self.process_iteration(title, description, widget, t0)
6163

6264

6365
if __name__ == '__main__':

0 commit comments

Comments
 (0)