I'm curious as to if there is a good rule of thumb as to when it is faster to use maps or temporary documents to store data. I was surprised to find recently that switching from temporary documents to maps doubled the time of processing. I had expected maps to perhaps be a bit faster, especially in this case because the temporary documents were essentially just emulating a map.
The algorithm in question essentially models flow along a directed network.
It takes in a temporary document giving the current "water level" at each node and outputs the water level at each node after 1 time increment. This output is fed back as input to calculate the water levels at the next second.
For the original algorithm, the data was exchanged with the basic structure of
<to y="node id" value="water level"/>. In each iteration a sequence of these was fed in and a new sequence was calculated and spit out: