Question about Matplotlib system performance

I am interested in using Matplotlib for real-time updating plot applications. My concern is with system load issues (they’re pretty high). Using the code below, which came off of an earlier posting to this list, on a pc (2.4 gig processor) memory usage ranges from 20 - 50+ megs (there’s a cycling pattern) and 30-40% of the cpu is being used for this basic app. If left to run for 20 minutes or so, it seems to crash (entire screen turns grey and reboot is required to get machine back to working order).

On a solaris machine, the performance numbers are similar, though the memory didn’t appear to exceed 30 megs (or cycle). One other solaris issue is that the plot doesn’t update, unless it is forced to redraw (by moving another window over the plot window). I’ve tinkered with the redraw rate, but it didn’t seem to help.

Short of the performance issues, this software looks great. Is there a way of using the software that will minimize system impact, or better yet, can this become a development priority? It’s not clear if the performance issue is driven by matplotlib, pygtk or gtk. Is it possible that different backends lead to non-trivial differences in performance?

Also, the crashing on a pc and non-updating on solaris are outstanding concerns.

Derek Bandler


import pygtk
import gtk
import time
from matplotlib.matlab import *

def get_memory():
“Simulate a function that returns system memory”
return 100*(1+sin(0.5pitime.time()))

def get_cpu():
“Simulate a function that returns cpu usage”
return 100*(1+sin(0.2pi(time.time()-0.25)))

def get_net():
“Simulate a function that returns network bandwidth”
return 100*(1+sin(0.7pi(time.time()-0.1)))

def get_stats():
return get_memory(), get_cpu(), get_net()

fig = figure(1)
ax = subplot(111)
ind = arange(1,4)
pm, pc, pn = bar(ind, get_stats())
centers = ind + 0.5*pm.get_width()

ax.set_xticklabels([‘Memory’, ‘CPU’, ‘Bandwidth’])
ax.set_ylabel(‘Percent usage’)
ax.set_title(‘System Monitor’)

def updatefig(*args):
m,c,n = get_stats()


return gtk.TRUE

gtk.timeout_add(250, updatefig)

Create your own personal Web page with the info you use most, at My MSN.