[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] profiling the waterfall

From: David Carr
Subject: [Discuss-gnuradio] profiling the waterfall
Date: Wed, 09 Mar 2005 02:46:44 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041227 MultiZilla/

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()

       if self.info.input_is_real:
           d_max = l/2
           p_width = 2
           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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]