Hi,
I have a UDP client in C. I need to profile this program. I have used gprof. Now the makefile looks like:
Code:
all: UDPClientProject
#Macro definitions
CC = gcc
CFLAGS = -lm
INCLUDES = -I/usr/include/mysql
LIBS = -L/usr/lib/mysql -lmysqlclient
xTRClient.o: xTRClient.c map_registration.h
$(CC) $(CFLAGS) -pg -c xTRClient.c
TCP_server_address_db.o: TCP_server_address_db.c map_registration.h
$(CC) $(CFLAGS) $(INCLUDES) -pg -c TCP_server_address_db.c
UDPClientProject: xTRClient.o TCP_server_address_db.o
$(CC) -pg -o UDPClientProject xTRClient.o TCP_server_address_db.o $(LIBS)
clean:
-rm xTRClient.o TCP_server_address_db.o
After the program runs (its a large code, so it takes a while), the output for the profile looks like (important parts are only shown):
Code:
Flat profile:
Each sample counts as 0.01 seconds.
no time accumulated
% cumulative self self total
time seconds seconds calls Ts/call Ts/call name
0.00 0.00 0.00 100 0.00 0.00 append
0.00 0.00 0.00 8 0.00 0.00 delete_query
0.00 0.00 0.00 8 0.00 0.00 get_map_notify_packet
0.00 0.00 0.00 8 0.00 0.00 insert_query
0.00 0.00 0.00 8 0.00 0.00 map_notify_packet_initialization
0.00 0.00 0.00 8 0.00 0.00 map_register_packet_initialization
0.00 0.00 0.00 8 0.00 0.00 tcp_server_access_main
0.00 0.00 0.00 1 0.00 0.00 access_file_insert_data
................................
granularity: each sample hit covers 4 byte(s) no time propagated
index % time self children called name
0.00 0.00 100/100 access_file_insert_data [8]
[1] 0.0 0.00 0.00 100 append [1]
-----------------------------------------------
0.00 0.00 8/8 tcp_server_access_main [7]
[2] 0.0 0.00 0.00 8 delete_query [2]
-----------------------------------------------
0.00 0.00 8/8 main [15]
[3] 0.0 0.00 0.00 8 get_map_notify_packet [3]
-----------------------------------------------
0.00 0.00 8/8 tcp_server_access_main [7]
[4] 0.0 0.00 0.00 8 insert_query [4]
-----------------------------------------------
0.00 0.00 8/8 main [15]
[5] 0.0 0.00 0.00 8 map_notify_packet_initialization [5]
-----------------------------------------------
0.00 0.00 8/8 main [15]
[6] 0.0 0.00 0.00 8 map_register_packet_initialization [6]
-----------------------------------------------
0.00 0.00 8/8 main [15]
[7] 0.0 0.00 0.00 8 tcp_server_access_main [7]
0.00 0.00 8/8 delete_query [2]
0.00 0.00 8/8 insert_query [4]
-----------------------------------------------
0.00 0.00 1/1 main [15]
[8] 0.0 0.00 0.00 1 access_file_insert_data [8]
0.00 0.00 100/100 append [1]
-----------------------------------------------
Please tell me if I had done something wrong or not in the makefile.
Most importantly, why are all the time 0.0. The program is large and it takes quite a lot of time. Why am I getting 0.0 instead of the actual time?
Another question is: how do u use gprof with a UDP server program. Because as u know, the UDP server goes into an infinite loop and I have to press CTRL+C to stop. If I stop the program in this way, then gmon.out doesn't get generated. What should I do?
Bye.