I've spent some time profiling the waterfallsink code. Currently its pretty
abominably slow. I'm using python's profile module to do the following.
For a given run:
total run time on cpu as reported by the command "time"
real 0m17.874s
user 0m16.364s
sys 0m0.883s
python profile module reported total run time:
8.06 sec (8.06 is 45% of 17.87)
Where does the rest of the time go?
Here's the 8.06 sec broken down:
set_data() 92%
set_data_loop() 86%
dc1.SetPen(dc1.SetPen(wx.Pen(colour, 1, wx.SOLID)) 51%
dc1.SetBrush(wx.Brush(colour, wx.SOLID)) 28%
dc1.DrawRectangle(x_pos*p_width, 0, p_width, 1) 7%
The offending code (broken into parts for profiling)
def set_data_loop_draw(self, dc1, x_pos, p_width, value):
colour = wx.Colour(value, value, value)
dc1.SetPen(wx.Pen(colour, 1, wx.SOLID))
dc1.SetBrush(wx.Brush(colour, wx.SOLID))
dc1.DrawRectangle(x_pos*p_width, 0, p_width, 1)
def set_data_loop(self, dc1, dB, d_max, p_width):
for x_pos in range(0, d_max):
value = int(dB[x_pos] * 1.5)
if value > 255:
value = 255
elif value < 0:
value = 0
self.set_data_loop_draw(dc1, x_pos, p_width, value)
def set_data (self, evt):
data = evt.data
dB = 20 * Numeric.log10 (abs(data) + 1e-8)
l = len (dB)
dc1 = wx.MemoryDC()
dc1.SelectObject(self.bm)
dc1.Blit(0,1,self.info.fft_size,300,dc1,0,0,wx.COPY,False,-1,-1)
if self.info.input_is_real:
d_max = l/2
p_width = 2
else:
d_max = l
p_width = 1
self.set_data_loop(dc1, dB, d_max, p_width)
self.DoDrawing (None)
Where do we go from here? I should note that the loop is not actually that
slow, its just gets iterates for every drawn pixel. That translates to
18,432 calls to the loop itself in 8.06 seconds at 512 iterations per call.
Ideally this loop could be eliminated if there were a way to plot a vector
rather than each point individually. That would be very nice indeed.
It would also be nice to know where the other 17 - 8.06 = ~9 seconds go that
profiling doesn't account for...
-David Carr
_______________________________________________
Discuss-gnuradio mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio