A programmer friend of mine says it needs to count framebuffer flips?
Anyway, for this to be useful at all it needs to work with nvidia/ati drivers, so I suppose hacking up drivers is out of the question.
The big problem lies in that there is no answers for you that don't require a bit of programming effort on your part at this time.
BuGlE will compile out of box on most systems without user intervention- but it requires a smidge of understanding about how to drive it, which isn't easy because it's more a debugging tool for developers than what you're actually looking for. It will, however do precisely what you're looking for. But...as I've said, there's a bit of assembly required for the parts to make it go. And it'll work with just about any 3D drivers for Linux.
Getting started with BuGLE, setting it up to log framerates to a file, and then processing it with awk or something similar to get get the average framerate isn't that hard, and you can probably get all the help you need here in the forum.
Not sure if it fits with what you're trying to accomplish though?