I re-wrote the data inserting mechanism for the GrabPERF script. Previously, I had been looping through the measurements, then looping through the results to insert them.
Now I open two database connections, loop through the measurements and insert them after the data is collected. Much more efficient, although I am still a hack programmer.
I will be glad to share a sanitized version of the measurement script with anyone who asks.