Determining C code's processor cache efficiency
===

I'd like to determine how efficiently given C code utilises processor cache, and if possible, determine what data is present in the cache and what is stored in main memory (though that is more of a nice-to-have) - is there software out there that can do this?

I know this may not fit into the remit of stack overflow, though of course it is highly related to programming as I intend to use it as a tool to test code I am writing. If there is a more appropriate place, please let me know/mods move this question.

Additionally, I'd (much) prefer the software to be for mac os x/unix.

Thanks!