I just preformed tests to determine what part of the rendering code was slow.
I modified the draw_poly_collection function by putting statements in that print out the time (using the C clock() function) at certain points in the program.
My results were:
Almost all the time spend in draw_poly_collection was inside the rendering loop. (the rendering loop is between checkpoints 4 and 5) In fact, the time it took to get through the parts before the rendering loop was so short I couldn’t even measure it with clock(). However it did take some time after I called show() for it to get to draw_poly_collection.
I divided the rendering loop up into 5 sections and determined how much time was spent in each one. From the start of the loop to when I increase timeOne is the first segment, from then to when I increase timeTwo is the second segment, and so on. The results are shown in the attached spreadsheet. N is the width and height of the mesh (n=100 means a 100 x 100 mesh).The “pre-rendering time” is the time it is running before it gets to the rendering part, measured by the value of clock() when the draw_poly_collection function is entered.
All the parts of the loop take a sizable amount of time. This means that it’s probably not a simple problem like it was with pcolor().
When drawing a pcolor plot, we probably don’t need to render the edges of each box. The “edges” just cause the whole thing to be black anyway when the resolution is high enough. Again, this isn’t a problem with draw_poly_collection, but it is a reminder that we can save time by not rendering the edges if we don’t need to. We could probably change pcolor() so that by default, it makes the alpha value of the edges zero (so they won’t get rendered) and just have a keyword argument to override that.
Section 2 takes the most time, and the only thing in that section that seems like it might be taking a lot of time is the transform->operator() call. We need to figure out what that is so we can see if it can be speeded up or bypassed.
The modified _backend_agg.cpp is attached. Also, I found a single character error in the axes.py I sent you before, which was making it draw triangles instead of squares. The corrected axes.py is attached.
Test results.xls (15 KB)
_backend_agg.cpp (54.8 KB)
axes.py (147 KB)