OK, sorry for my first answer. Later I read your subsequent comments under your question, so now I understand that you want to clear INSTRUCTION CACHE in order to load your program (or parts of it) from the cache, so that while checking its performance you also tested its initial load time from main memory in command cache. Do you also need to clear any data that your code will use in main memory so that the data and code are fresh?
First of all, I would like to mention that main memory itself is also a form of cache, and your hard drive (either a program on disk or a swap space on disk) is the lowest and slowest place for your program instructions to occur. However, when you first start the procedure for the first time, if it is not already loaded into the main memory from the disk due to the fact that it is next to another code that has already been executed, then its CPU commands from the disk must be loaded first. This takes about or more longer than loading it from main memory into the cache. Then, as soon as it is loaded into the main memory, it takes about an order of magnitude more time to load from the main memory to the cache than it does to load from the cache into the processor instruction collector. Therefore, if you want to test the performance of your cold start code, you need to decide what a cold start means ... pulling it out of the disk or pulling it out of main memory. I don’t know any command to “flush” instructions / data from the main memory in order to swap, so flushing to the main memory is about the same as you can (what I know), but keep in mind that your test results may still vary from the first run (when he can pull it out of the disk) into subsequent runs, even if you dumped the command cache.
Now, how could you clear the command cache to make sure that their own code has been dumped into main memory?
If I needed it (very strange, in my opinion), I would probably start by looking for the length and approximate placement of my functions in memory. Since I use Linux, I would issue the command "objdump -d {myprogram}> myprogram.dump.txt", then I would open the myprogram.dump.txt file in the editor and search for the functions that I want to reset and find out how long they subtract your final address from your starting address using a hexadecimal calculator. I would write down the sizes of each of them. Later I added cacheflush () calls in my code, giving it the address of each function that I want to reset as "addr", and the length that I found as "nbytes", and ICACHE. Just for safety, I probably lost a little weight and added about 10% to the size, just in case I make a few settings in the code and forget to adjust nbytes. I would make a call to cacheflush (), like this for every function I want to disable. Then, if I also need to wash the data, if they use global / static data, I can also clear it (DCACHE), but if it adds or accumulates data, there really is nothing realistic that I can (or should) do for a flash that from cache. Trying to do this would be an exercise in stupidity, because it would create a condition that would never or very rarely exist under normal execution. Assuming you are using Linux ...
By the way, is this homework for the class?