I am trying to profile a C program I've made of pagerank for an assignment. I have a mac so can't use gprof so have checked out the xcode instruments application. I have loaded the target as the C executable.
I compiled my C program with this makefile:
CC = clang
CFLAGS = -g -O1 -Wall -Werror -std=gnu11 -march=native
LDFLAGS = -lm -pthread
.PHONY: all clean
all: pagerank
pagerank: pagerank.c
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
clean:
-rm -f *.o
-rm -f pagerank
-rm -rf *.dSYM
The issue is that I press the record button and it starts and stops instantly. The count of runs increments each time as if it had successfully run.
I am unsure what I am meant to do differently. My understanding was that I would point the target to my executable, hit record and then go into terminal and run a test however this doesn't seem to work.
Is your program interactive? If so, you can start it normally in Terminal and then attach Instruments to the already-running process. Of course, you won't be profiling the program's start-up.
If your program is not interactive, then you should set up the arguments and environment in the Choose Target dialog so that when Instruments runs it, it does what you want to profile.