From: Darren D. <dd...@co...> - 2006-03-20 17:41:19
|
On Monday 20 March 2006 11:05, John Hunter wrote: > I ran a test script to profile this before and after, making marker > plots of various sizes. I think you'll be happy with the fruits of > your labors. Because we save the effort of setting a gc for each > marker, and thus avoid of lot of redundant function calling and state > setting in the output file, the results are much better in time and space > > import time, os > from pylab import figure, close, nx > > for i in 10,100,1000,10000,100000: > fig = figure(1) > ax = fig.add_subplot(111) > x,y = nx.mlab.rand(2,i) > tnow = time.time() > ax.plot(x,y, 'o') > fname = 'file%d.ps' > fig.savefig(fname) > elapsed = time.time() - tnow > fsize = os.stat(fname)[6] > print 'i=%06d time= %1.2fs size=%1.1fkb'%(i, elapsed, fsize/1e3) > close(1) > > Old API: > > python test.py > > i=000010 time= 0.33s size=142.4kb > i=000100 time= 0.30s size=154.9kb > i=001000 time= 0.43s size=284.1kb > i=010000 time= 1.79s size=1575.9kb > i=100000 time= 15.37s size=14495.6kb > > New API: > > python test.py > > i=000010 time= 0.53s size=148.1kb > i=000100 time= 0.29s size=146.5kb > i=001000 time= 0.30s size=163.6kb > i=010000 time= 0.44s size=334.5kb > i=100000 time= 2.17s size=2044.5kb > > So for largish marker plots, you have about a 7x improvement in speed > and filesize. You may want to use this script to profile and see if > you can't eke out some extra gains. Maybe another 2x <wink>. This is > using the default rc file. > > Now that we have a good implementation in a pure python backend that > others can follow as an example, I will shortly deprecate the old API > entirely and begin pruning the redundant methods. Considering that > both your changes and Eric's are significant enhancements, we may wait > to do this until one release cycle down the road, so that we don't > delay getting these out to the wider community. I just committed a fix for a minor bug, it didnt effect the performance. My results are comparable to yours. How's this for a performance boost: set ps.useafm : true in rc: Old API: i=000010 time= 0.09s size=6.2kb i=000100 time= 0.07s size=18.0kb i=001000 time= 0.19s size=147.2kb i=010000 time= 1.43s size=1439.2kb i=100000 time= 13.99s size=14358.6kb New API: i=000010 time= 0.16s size=11.7kb i=000100 time= 0.07s size=9.6kb i=001000 time= 0.06s size=26.7kb i=010000 time= 0.13s size=197.7kb i=100000 time= 0.75s size=1907.7kb I dont see where I can make things any faster in draw_markers, we trimmed all the fat when we started on this a year ago. Here's a bug: I need isnan to create my mask. It is provided by numerix with numpy and numarray, but not Numeric. Can this be rectified? Darren |