From 41c3d47d4334f71b7bd2a6cf543755f06b26de22 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Wed, 5 Mar 2014 10:25:55 -0500 Subject: [PATCH] Correct GraphicsItem to use relative import of lru_cache Update MultiPlotSpeedTest to test lru_cache performance --- examples/MultiPlotSpeedTest.py | 21 +++++++++++++++------ examples/__main__.py | 1 + pyqtgraph/graphicsItems/GraphicsItem.py | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/examples/MultiPlotSpeedTest.py b/examples/MultiPlotSpeedTest.py index e38c90e2..0d0d701b 100644 --- a/examples/MultiPlotSpeedTest.py +++ b/examples/MultiPlotSpeedTest.py @@ -22,17 +22,25 @@ p.setWindowTitle('pyqtgraph example: MultiPlotSpeedTest') #p.setRange(QtCore.QRectF(0, -10, 5000, 20)) p.setLabel('bottom', 'Index', units='B') -nPlots = 10 +nPlots = 100 +nSamples = 500 #curves = [p.plot(pen=(i,nPlots*1.3)) for i in range(nPlots)] -curves = [pg.PlotCurveItem(pen=(i,nPlots*1.3)) for i in range(nPlots)] -for c in curves: +curves = [] +for i in range(nPlots): + c = pg.PlotCurveItem(pen=(i,nPlots*1.3)) p.addItem(c) + c.setPos(0,i*6) + curves.append(c) -rgn = pg.LinearRegionItem([1,100]) +p.setYRange(0, nPlots*6) +p.setXRange(0, nSamples) +p.resize(600,900) + +rgn = pg.LinearRegionItem([nSamples/5.,nSamples/3.]) p.addItem(rgn) -data = np.random.normal(size=(53,5000/nPlots)) +data = np.random.normal(size=(nPlots*23,nSamples)) ptr = 0 lastTime = time() fps = None @@ -42,7 +50,8 @@ def update(): count += 1 #print "---------", count for i in range(nPlots): - curves[i].setData(i+data[(ptr+i)%data.shape[0]]) + curves[i].setData(data[(ptr+i)%data.shape[0]]) + #print " setData done." ptr += nPlots now = time() diff --git a/examples/__main__.py b/examples/__main__.py index e7dbe5eb..efd6ea06 100644 --- a/examples/__main__.py +++ b/examples/__main__.py @@ -53,6 +53,7 @@ examples = OrderedDict([ ('Video speed test', 'VideoSpeedTest.py'), ('Line Plot update', 'PlotSpeedTest.py'), ('Scatter Plot update', 'ScatterPlotSpeedTest.py'), + ('Multiple plots', 'MultiPlotSpeedTest.py'), ])), ('3D Graphics', OrderedDict([ ('Volumetric', 'GLVolumeItem.py'), diff --git a/pyqtgraph/graphicsItems/GraphicsItem.py b/pyqtgraph/graphicsItems/GraphicsItem.py index 5c941dae..2cae5d20 100644 --- a/pyqtgraph/graphicsItems/GraphicsItem.py +++ b/pyqtgraph/graphicsItems/GraphicsItem.py @@ -4,7 +4,7 @@ from ..Point import Point from .. import functions as fn import weakref import operator -from pyqtgraph.lru_cache import LRUCache +from ..util.lru_cache import LRUCache class GraphicsItem(object):