Is it possible to profile a Ruby application to see how much it interacts with the file system?
Background: In the past I’ve written code that reads files within a loop when it only needs to do so once. I’d like to make sure that I eliminate all such code.
There are already perfectly capable programs for this purpose out there, that you don’t need to duplicate. I don’t think you should complicate your program with special logic checking for a relatively obscure programming error (at least, I’ve never accidentally committed the error you describe). In such cases, the solution is to check a performance characteristic from outside the program. Assuming you are on Linux, I would turn to a test/spec that exercises your code and watches iostat (or similar) in a seperate thread.