LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-16-2011, 12:26 AM   #1
manohar
Member
 
Registered: Dec 2010
Posts: 42

Rep: Reputation: 2
Smile Cpu utilization


Hi,

Any one has idea how to find cpu utilization of functions in a process in linux platform.
top command will give process cpu utilization. I need to know cpu utilization of individual functions in the process..
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 12-16-2011, 01:32 AM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 211Reputation: 211Reputation: 211
Try gprof or oprofile.
 
Old 12-16-2011, 04:49 AM   #3
manohar
Member
 
Registered: Dec 2010
Posts: 42

Original Poster
Rep: Reputation: 2
Smile

When i try to use "gprof" i am getting following message as output

Used :
gcc -lpthread -pg -g multicode.c -o gp-test
gprof gp-test

multicode.c has 3functions...

Quote:
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

% the percentage of the total running time of the
time program used by this function.

cumulative a running sum of the number of seconds accounted
seconds for by this function and those listed above it.

self the number of seconds accounted for by this
seconds function alone. This is the major sort for this
listing.

calls the number of times this function was invoked, if
this function is profiled, else blank.

self the average number of milliseconds spent in this
ms/call function per call, if this function is profiled,
else blank.

total the average number of milliseconds spent in this
ms/call function and its descendents per call, if this
function is profiled, else blank.

name the name of the function. This is the minor sort
for this listing. The index shows the location of
the function in the gprof listing. If the index is
in parenthesis it shows where it would appear in
the gprof listing if it were to be printed.
 
Old 12-16-2011, 05:23 AM   #4
dig2tech
LQ Newbie
 
Registered: Dec 2011
Posts: 2

Rep: Reputation: 0
Solution

Quote:
Originally Posted by manohar View Post
Hi,

Any one has idea how to find cpu utilization of functions in a process in linux platform.
top command will give process cpu utilization. I need to know cpu utilization of individual functions in the process..
Hello Try with Sar or vmstat. It gives more info to you.
 
Old 12-16-2011, 07:31 AM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Probably the simplest way to do that sort of thing is to build instrumentation into the program itself: snapshot the timer before-and-after. Or, measure the system in terms of the work that it is actually doing, "for its customers" instead of "for the CPUs." One benefit of this strategy is that you can leave the instrumentation in, and you can glean statistics with minimal impact. The execution environment created by a profiler can be very different from the one that a program experiences in "normal" operation.

Another consideration is that, with multiple CPUs, many things can be happening at the same time such that a profiler's output is quite difficult to map to useful program improvements. I therefore prefer to try to understand a machine's operation in terms of what's going in and what's coming out (and when...), vs. counting the rotations of the internal gears.

Last edited by sundialsvcs; 12-16-2011 at 07:33 AM.
 
Old 12-16-2011, 08:18 AM   #6
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Hello manohar,

Simply you can use mpstat or vmstat -a.

Output of mpstat on my RHEL5.3 Server:
07:46:36 PM CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s
07:46:36 PM all 0.77 0.00 0.12 0.68 0.00 0.05 0.00 98.38 694.26


Output of vmstat -a :
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free inact active si so bi bo in cs us sy id wa st
0 0 263512 46396 2105472 4364256 0 0 6 28 0 0 1 0 98 1 0

Last edited by Satyaveer Arya; 12-16-2011 at 08:20 AM.
 
2 members found this post helpful.
  


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
CPU Utilization mail2mphani Linux - Hardware 12 09-14-2010 01:48 AM
High CPU utilization on only one CPU out of 4 CPUs makam.sreekanth Linux - Kernel 2 09-03-2009 04:12 AM
cpu utilization and cpu load soltanloo Linux - General 1 06-07-2009 02:19 AM
Linux desktop GUI tool for CPU utilization and bandwidth utilization karimasif Linux - Software 4 03-03-2008 01:09 PM
CPU utilization in 2.4 vs 2.6.. lynz Linux - Software 2 06-04-2007 01:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:01 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