LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-25-2011, 08:09 AM   #1
anis_huq
LQ Newbie
 
Registered: Nov 2006
Posts: 29

Rep: Reputation: 0
Problem with profiling tool gprof


Hi,
I am using UBUNTU 10.10 Maverick.
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.

Last edited by anis_huq; 10-25-2011 at 08:11 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gprof and -pg(profiling): does it affect the speed of your application? jaepi Linux - Software 1 05-12-2008 05:13 AM
Profiling Standard C library functions using gprof ecooper Programming 1 01-08-2007 09:46 AM
gprof and execution profiling astropirhana Programming 1 10-24-2006 12:16 PM
Profiling tool required Sambatyon Programming 1 07-30-2005 04:17 PM
Profiling daemon threads in Linux.. which tool? devershetty Linux - Software 0 07-20-2004 09:17 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration