Skip to content

Commit 7affb9b

Browse files
committed
Added load test showing a large number of plots
1 parent dad7947 commit 7affb9b

File tree

4 files changed

+77
-9
lines changed

4 files changed

+77
-9
lines changed

qwt/tests/curvebenchmark1.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,16 @@ def get_curve_color():
4646
return colors[COLOR_INDEX]
4747

4848

49+
PLOT_ID = 0
50+
51+
4952
class BMPlot(QwtPlot):
5053
def __init__(self, title, xdata, ydata, style, symbol=None, *args):
5154
super(BMPlot, self).__init__(*args)
52-
self.setMinimumSize(200, 200)
53-
self.setTitle(title)
55+
global PLOT_ID
56+
self.setMinimumSize(200, 150)
57+
PLOT_ID += 1
58+
self.setTitle("%s (#%d)" % (title, PLOT_ID))
5459
self.setAxisTitle(QwtPlot.xBottom, "x")
5560
self.setAxisTitle(QwtPlot.yLeft, "y")
5661
self.curve_nb = 0
@@ -69,11 +74,11 @@ def __init__(self, title, xdata, ydata, style, symbol=None, *args):
6974

7075

7176
class BMWidget(QWidget):
72-
def __init__(self, points, *args, **kwargs):
77+
def __init__(self, nbcol, points, *args, **kwargs):
7378
super(BMWidget, self).__init__()
7479
self.plot_nb = 0
7580
self.curve_nb = 0
76-
self.setup(points, *args, **kwargs)
81+
self.setup(nbcol, points, *args, **kwargs)
7782

7883
def params(self, *args, **kwargs):
7984
if kwargs.get("only_lines", False):
@@ -84,11 +89,11 @@ def params(self, *args, **kwargs):
8489
("Dots", None),
8590
)
8691

87-
def setup(self, points, *args, **kwargs):
92+
def setup(self, nbcol, points, *args, **kwargs):
8893
x = np.linspace(0.001, 20.0, int(points))
8994
y = (np.sin(x) / x) * np.cos(20 * x)
9095
layout = QGridLayout()
91-
nbcol, col, row = 2, 0, 0
96+
col, row = 0, 0
9297
for style, symbol in self.params(*args, **kwargs):
9398
plot = BMPlot(style, x, y, getattr(QwtPlotCurve, style), symbol=symbol)
9499
layout.addWidget(plot, row, col)
@@ -102,7 +107,7 @@ def setup(self, points, *args, **kwargs):
102107
self.text.setReadOnly(True)
103108
self.text.setAlignment(Qt.AlignCenter)
104109
self.text.setText("Rendering plot...")
105-
layout.addWidget(self.text, row + 1, 0, 1, 2)
110+
layout.addWidget(self.text, row + 1, 0, 1, nbcol)
106111
self.setLayout(layout)
107112

108113

@@ -171,7 +176,7 @@ def run_benchmark(self, max_n, **kwargs):
171176
for idx in range(4, -1, -1):
172177
points = int(max_n / 10 ** idx)
173178
t0 = time.time()
174-
widget = BMWidget(points, **kwargs)
179+
widget = BMWidget(2, points, **kwargs)
175180
title = "%d points" % points
176181
description = "%d plots with %d curves of %d points" % (
177182
widget.plot_nb,

qwt/tests/curvebenchmark2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def run_benchmark(self, max_n, **kwargs):
7474
):
7575
t0 = time.time()
7676
symtext = "with%s symbols" % ("" if symbols else "out")
77-
widget = CSWidget(points, symbols, **kwargs)
77+
widget = CSWidget(2, points, symbols, **kwargs)
7878
title = "%d points" % points
7979
description = "%d plots with %d curves of %d points, %s" % (
8080
widget.plot_nb,

qwt/tests/data/loadtest.png

131 KB
Loading

qwt/tests/loadtest.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Licensed under the terms of the MIT License
4+
# Copyright (c) 2015-2021 Pierre Raybaut
5+
# (see LICENSE file for more details)
6+
7+
"""Load test"""
8+
9+
SHOW = True # Show test in GUI-based test launcher
10+
11+
import time
12+
import os
13+
14+
# Local imports
15+
from qwt.tests import curvebenchmark1 as cb
16+
17+
18+
if os.environ.get("USE_PYQWT5", False):
19+
USE_PYQWT5 = True
20+
from PyQt4.Qwt5 import QwtPlot, QwtPlotCurve
21+
else:
22+
USE_PYQWT5 = False
23+
from qwt import QwtPlot, QwtPlotCurve # analysis:ignore
24+
25+
26+
NCOLS, NROWS = 6, 5
27+
NPLOTS = NCOLS * NROWS * 5 * 3
28+
29+
30+
class LTWidget(cb.BMWidget):
31+
def params(self, *args, **kwargs):
32+
return tuple([("Lines", None)] * NCOLS * NROWS)
33+
34+
35+
class LoadTest(cb.CurveBenchmark1):
36+
TITLE = "Load test [%d plots]" % NPLOTS
37+
SIZE = (1600, 700)
38+
39+
def __init__(self, max_n=100, parent=None, unattended=False, **kwargs):
40+
super(LoadTest, self).__init__(
41+
max_n=max_n, parent=parent, unattended=unattended, **kwargs
42+
)
43+
44+
def run_benchmark(self, max_n, **kwargs):
45+
points, symbols = 100, False
46+
for _i_page in range(int(NPLOTS / (NCOLS * NROWS))):
47+
t0 = time.time()
48+
symtext = "with%s symbols" % ("" if symbols else "out")
49+
widget = LTWidget(NCOLS, points, symbols, **kwargs)
50+
title = "%d points" % points
51+
description = "%d plots with %d curves of %d points, %s" % (
52+
widget.plot_nb,
53+
widget.curve_nb,
54+
points,
55+
symtext,
56+
)
57+
self.process_iteration(title, description, widget, t0)
58+
59+
60+
if __name__ == "__main__":
61+
from qwt.tests import test_widget
62+
63+
app = test_widget(LoadTest, options=False)

0 commit comments

Comments
 (0)