Skip to content
tlecomte edited this page Sep 13, 2010 · 6 revisions

Here is a copy of a python profile from 2009/11/15 snapshot, running on Windows:

Sun Nov 15 23:53:19 2009    friture.cprof

         2714121 function calls in 470.227 CPU seconds

   Ordered by: internal time
   List reduced from 134 to 20 due to restriction <20>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1  395.406  395.406  470.451  470.451 {built-in method exec_}
    45137    8.235    0.000   14.190    0.000 {drawCanvas}
    30078    6.008    0.000    6.008    0.000 {numpy.fft.fftpack_lite.rfftf}
    39642    5.417    0.000    5.417    0.000 {built-in method drawPixmap}
    15040    4.941    0.000   31.349    0.002 friture.py:260(display_timer_slot)
    15040    4.457    0.000   23.992    0.002 friture.py:299(spectrogram_timer_slot)
    15039    4.185    0.000    4.251    0.000 spectplot.py:111(compute_peaks)
    30078    4.037    0.000   13.853    0.000 audioproc.py:23(analyzelive)
    30080    3.892    0.000    5.862    0.000 friture.py:316(update_buffer)
    45117    2.968    0.000    2.968    0.000 {numpy.lib._compiled_base.interp}
    24597    2.249    0.000    4.291    0.000 qsynthmeter.py:167(paintEvent)
    15039    1.957    0.000    6.207    0.000 friture.py:377(levels)
    45133    1.932    0.000    2.344    0.000 function_base.py:35(linspace)
    75196    1.518    0.000    1.518    0.000 {built-in method canvas}
    75201    1.228    0.000    1.228    0.000 {method 'max' of 'numpy.ndarray' objects}
    30078    1.123    0.000    1.976    0.000 qsynthmeter.py:119(refresh)
    45117    0.948    0.000    0.948    0.000 {method 'astype' of 'numpy.ndarray' objects}
    15039    0.708    0.000    2.891    0.000 timeplot.py:51(setdata)
    15039    0.706    0.000    7.877    0.001 spectplot.py:84(setdata)
    15039    0.697    0.000    3.754    0.000 audiodata.py:163(finish_line)

Ideas to improve this :

  • use decimation when possible to reduce the time needed by “{numpy.fft.fftpack_lite.rfftf}”
  • cache the canvas pointer to remove “{built-in method canvas}”
  • cache the frequency scale to remove “function_base.py:35(linspace)”
  • investigate the time spent in “friture.py:316(update_buffer)” by splitting in more functions
  • do the log10 conversion on the spectrum after interpolation, which often reduces the number
    of points in the spectrum, would probably reduce “friture.py:260(display_timer_slot)” and
    “friture.py:299(spectrogram_timer_slot)”
  • split other calls to see more precisely where the cost comes from

Note: on other platforms, the profile’s most offenders may be different

Now here is a copy of a python profile from 2009/11/17 snapshot, running on MacOS X Leopard:

Tue Nov 17 08:54:57 2009    friture.cprof

         412295 function calls in 53.961 CPU seconds

   Ordered by: internal time
   List reduced from 127 to 20 due to restriction <20>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1   37.668   37.668   53.970   53.970 {built-in method exec_}
     6257    5.562    0.001    5.562    0.001 {built-in method drawPixmap}
     6912    2.335    0.000    7.686    0.001 {drawCanvas}
     4822    0.625    0.000    1.801    0.000 audioproc.py:28(analyzelive)
     2084    0.608    0.000    0.610    0.000 spectplot.py:119(compute_peaks)
     4822    0.563    0.000    0.563    0.000 {numpy.fft.fftpack_lite.rfftf}
     4823    0.539    0.000    0.680    0.000 friture.py:293(update_buffer)
    11075    0.478    0.000    0.478    0.000 {built-in method canvas}
     2738    0.472    0.000    2.922    0.001 friture.py:275(spectrogram_timer_slot)
     7560    0.361    0.000    0.361    0.000 {method 'astype' of 'numpy.ndarray' objects}
     2084    0.346    0.000    1.030    0.000 friture.py:354(levels)
     6906    0.328    0.000    0.328    0.000 {numpy.lib._compiled_base.interp}
     3517    0.261    0.000    1.000    0.000 qsynthmeter.py:167(paintEvent)
     2084    0.240    0.000    2.095    0.001 friture.py:385(spectrum)
     5476    0.205    0.000    0.205    0.000 {built-in method drawImage}
     2084    0.194    0.000    0.930    0.000 friture.py:367(scope)
    10424    0.183    0.000    0.183    0.000 {method 'max' of 'numpy.ndarray' objects}
     7070    0.181    0.000    0.181    0.000 {built-in method drawLine}
     4168    0.171    0.000    0.320    0.000 qsynthmeter.py:119(refresh)
     3518    0.159    0.000    0.159    0.000 {built-in method fillRect}

In this profile drawCanvas and drawPixmap take much more time than the rest. Why ?

Clone this wiki locally