Menu

[r303]: / trunk / htdocs / examples / backend_driver.py  Maximize  Restore  History

Download this file

98 lines (88 with data), 2.8 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env python
"""
This is use to drive many of the examples across the image backends
and is used for regression testing and comparing backend efficiency
This example creates a lot of temp files name _tmp_*.py. You'll
probably want to remove them after the script runs
"""
from __future__ import division
import os, time
files = (
'alignment_test.py',
'arctest.py',
'axes_demo.py',
'bar_stacked.py',
'barchart_demo.py',
'color_demo.py',
'csd_demo.py',
'date_demo1.py',
'date_demo2.py',
'fill_demo.py',
'figtext.py',
'finance_demo.py',
'histogram_demo.py',
'image_demo.py',
'image_demo2.py',
'image_demo_na.py',
'invert_axes.py',
'legend_demo.py',
'legend_demo2.py',
'line_styles.py',
'log_demo.py',
'log_test.py',
'mathtext_demo.py',
# 'mri_with_eeg.py',
'major_minor_demo1.py',
'major_minor_demo2.py',
'multiple_figs_demo.py',
'pcolor_demo.py',
'pcolor_demo2.py',
'psd_demo.py',
'scatter_demo.py',
'scatter_demo2.py',
'simple_plot.py',
'stock_demo.py',
'specgram_demo.py',
'subplot_demo.py',
'table_demo.py',
'text_handles.py',
'text_themes.py',
)
def drive(backend):
for fname in files:
lines = [
'from __future__ import division\n',
'import matplotlib\n',
'matplotlib.use("%s")\n' % backend]
print '\tdriving %s' % fname
for line in file(fname):
if line.strip().startswith('from __future__ import division'): continue
if line.strip().startswith('matplotlib.use'): continue
if line.strip().startswith('savefig'): continue
if line.strip().startswith('show'): continue
lines.append(line)
basename, ext = os.path.splitext(fname)
outfile = basename + '_%s'%backend
if backend in ('GTK', 'WX', 'TkAgg'):
lines.append('show()')
else:
lines.append('savefig("%s", dpi=150)' % outfile)
tmpfile = '_tmp_%s.py' % basename
file(tmpfile, 'w').write(''.join(lines))
os.system('python %s' % tmpfile)
times = {}
backends = ['PS', 'GD', 'Paint', 'Agg', 'Template']
#backends.extend([ 'GTK', 'WX', 'TkAgg'])
#backends = [ 'Agg']
#backends = [ 'Agg', 'PS', 'Template']
for backend in backends:
print 'testing %s' % backend
t0 = time.time()
drive(backend)
t1 = time.time()
times[backend] = (t1-t0)/60.0
#print times
for backend, elapsed in times.items():
print 'Backend %s took %1.2f minutes to complete' % ( backend, elapsed)
print '\ttemplate ratio %1.3f, template residual %1.3f' % (
elapsed/times['Template'], elapsed-times['Template'])
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.