I'm trying to use Mac Instruments Time Profiler to optimize my code for building a MandelBox. I found how to make my executable my target process, but when the program runs, it gives me an error in the Console window saying it cannot find the .txt file associated with the program. Do I need to tell the profiler where to look to find the file? The text file is already in the same directory as the executable. Any thoughts? Thanks.
-
You can use the profiler, but there's a simple method that will find ways to speed up the code, that the profiler may not be able to find for you. [*Check the poor-man method.*](http://stackoverflow.com/a/378024/23771) – Mike Dunlavey Mar 26 '15 at 16:15
1 Answers
This problem is not unique to Instruments. The same thing would presumably happen if your current working directory was something other than the location of your program. For example, if you were to do cd / ; /path/to/yourprogram
.
You either need to make your program find its own location and then find its text file as a sibling in the containing directory or take the path of the text file as an argument. Or, you will always have to set the working directory to your program's location before invoking it.
That last approach is an immediate workaround for the problem with Instruments. On the panel where you choose the target executable, you can also configure various parameters, such as arguments, environment variables, and the working directory. Set the working directory to the directory that contains the text file and it should work.

- 88,520
- 7
- 116
- 154
-
Thanks! I set up the working directory as well as the input parameter using the full path, not just the file name, and it works now. – JacobMD Mar 23 '15 at 17:25