View Full Version : Profiling in Project Builder
Bachus
2002.06.22, 05:26 AM
Maybe I'm blind and this is actually in the docs, but how do you profile a build in Project Builder? All I can find is a build setting that supposedly turns profiling on, but I can't find where it outputs any info. All I can find in the docs is a casual mention of the build setting "PROFILING_CODE", but no mention of how it works (or even if it works).
Bachus
2002.06.22, 05:55 AM
Well I thought I had found out how to do it by using the -pg setting and gprof, but whenever I run gprof I get "gprof: file: gmon.out is unknown type (arch_flag to ofile_map() can't be specified to be other than NULL)". So looks like I need to keep looking.
Feanor
2002.06.22, 07:17 AM
I thought that project builder simply made the code ready for profiling and you used other tools to profile. Apple has a separate download of profiling tools on the tools page -- CHUD is one set of tools, tho that might be Jaguar only.
OneSadCookie
2002.06.22, 05:52 PM
The "generate profiling code" option doesn't work with my project -- it adds -pg to the compilation flags for all the .c/.m/.cpp/.mm/&c files, but it doesn't at -pg to the linking step. I just copied the link command out of the detailed build log, pasted it into the terminal, stuck -pg on the end and hit return. That worked.
I've seen the precise error you're reporting when I've tried to add profiling to my own command-line compiled programs, but haven't found why it does it or how to get around it.
HTH...
Bachus
2002.06.22, 06:42 PM
Okay thanks, I've got it. I found out about the -pg flag at some random Apple page. As for the error I found out that you need to include the path of your app as an argument to gprof, ie:
while in the "build" directory: gprof "My App.app"/Contents/MacOS/"My App" gmon.out
Thanks for the help! Now if I could only figure out why the path-finding code is causing the player not to draw...
OneSadCookie
2002.06.22, 07:47 PM
If you've got a recent G4, Shikari (a part of Apple's CHUD kit) is a very good profiler. Easy to use, doesn't require special compilation flags, gives very consistent results.
I'm sure it caused me a kernel panic at least once, though...
szymczyk
2002.06.22, 11:33 PM
Profiling Project Builder code has two sets of actions: the actions you perform inside Project Builder and outside Project Builder. Inside Project Builder, you must do the following:
1. In the Compiler Settings sections of the build settings, check the Generate Profiling Code checkbox.
2. In the Runtime tab of the Executables section, choose Profile for the Dynamic Library Runtime Variant.
3. Click the broom icon to rebuild your project to generate profiling data.
4. Run your program.
After running those steps you will get a gmon.out file. Now you must run the gprof program to generate the profile. You must run the Terminal application to get into the command line to run gprof. The gprof program has the following syntax:
gprof [Executable file name] [gmon.out] > [Output file name]
If you keep the name gmon.out, you don't need to explicitly type gmon.out. The hard part is that the executable file is 3 directories deeper than the gmon.out file. The easiest way to run gprof is to navigate to your project's build folder, then type the following:
gprof "GameTitle.app/Contents/MacOS/GameTitle" > OutputFile
where GameTitle is the name of your executable file and OutputFile is the name of the file that will contain the profile. It will take gprof a couple of minutes to generate the profile, then a file named OutputFile (or whatever you call it) will appear in your project's build folder. You can view this file in a text editor to see the results.
henryj
2002.06.23, 04:16 PM
Good reply szymczyk. I've been struggling with this for ages. Thanks
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.