It seems like you are using the function correctly. Unless you're using other stat functions (as listed in the doc) that you would prefer cached, I don't know of a reason it would cause a significant slowdown.
When you include('somefile')
, somefile
could be in a number of different locations, as determined by things like your include_path
, cwd, etc. The realpath cache just eliminates the need to repeatedly search these locations.
For your use, your code seems fine.