Forum archive 2000-2006

John Jones - Caching on-the-fly graphs

John Jones - Caching on-the-fly graphs

by Arnold Pizer -
Number of replies: 0
inactiveTopicCaching on-the-fly graphs topic started 9/19/2003; 11:11:07 AM
last post 9/19/2003; 11:11:07 AM
userJohn Jones - Caching on-the-fly graphs  blueArrow
9/19/2003; 11:11:07 AM (reads: 544, responses: 0)
In another thread, I made a throw-away comment about making a script to precreate on-the-fly graphs.  At the time, I just assumed that WW reused graphs which it had already created.  Looking at the code, I saw that they aren't.  If a problem has several graphs, they are all regenerated for each submission.

Reusing old graphs is easy.  It amounts to 2 lines of code inside the function insertGraph (an if statement to check the modification time on the source vs. the image, and a closing brace to match).  The hard part is adding code to clear out the images at all the times it is need (sets destroyed, reseeded, etc.).

Reusing old versions of graphs may not save as much time as old images because some of the work in creating them is unavoidable.  It is computation done in the problem itself to add lots of things to the graph object.  But, the actual plotting/creation of the graph can be short-cut.

On one server, I did a test on a problem with a single simple graph (2 lines plus a few labels).  The time for processProblem to render the initial graph was approximately 0.34 secs.  The time with caching code in place was approximately 0.26 secs.

I guess the question is whether this is worth it?

John

<| Post or View Comments |>