From 8f2b84cafc2ad1d47adde4e2fb5e4936b4e868d7 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 16 Jul 2015 23:33:10 -0400 Subject: [PATCH 1/2] DOC: slightly update demo Gets a frame rate of ~75fps on my machine --- examples/pylab_examples/system_monitor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/pylab_examples/system_monitor.py b/examples/pylab_examples/system_monitor.py index 90e5aa8de02e..a661570fc086 100644 --- a/examples/pylab_examples/system_monitor.py +++ b/examples/pylab_examples/system_monitor.py @@ -40,12 +40,15 @@ def get_stats(): ax.set_ylabel('Percent usage') ax.set_title('System Monitor') +start = time.time() for i in range(200): # run for a little while m, c, n = get_stats() pm.set_height(m) pc.set_height(c) pn.set_height(n) - ax.set_ylim([0, 100]) - plt.draw() + fig.canvas.flush_events() + +stop = time.time() +print("{fps:.1f} frames per second".format(fps=200 / (stop - start))) From 188d7a1727dadb3212f4d86bc95e268b80ac6b5c Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Fri, 17 Jul 2015 01:21:36 -0400 Subject: [PATCH 2/2] DOC: protect against non-gui backends in demo --- examples/pylab_examples/system_monitor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/pylab_examples/system_monitor.py b/examples/pylab_examples/system_monitor.py index a661570fc086..07110190a2c4 100644 --- a/examples/pylab_examples/system_monitor.py +++ b/examples/pylab_examples/system_monitor.py @@ -47,8 +47,10 @@ def get_stats(): pm.set_height(m) pc.set_height(c) pn.set_height(n) - - fig.canvas.flush_events() + try: + fig.canvas.flush_events() + except NotImplementedError: + pass stop = time.time() print("{fps:.1f} frames per second".format(fps=200 / (stop - start)))