GNU gprof Profiler Yu Kai Hong Department of Mathematics National Taiwan University July 19, 2008 GNU gprof 1/22.

Slides:



Advertisements
Similar presentations
Technotronics GCECT '091 Decode C This is a C Programming event, where you will be given problems to solve using C only. You will be given a Linux system.
Advertisements

Program Development Tools The GNU (GNU’s Not Unix) Toolchain The GNU toolchain has played a vital role in the development of the Linux kernel, BSD, and.
Intel® performance analyze tools Nikita Panov Idrisov Renat.
Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
SE-292 High Performance Computing Profiling and Performance R. Govindarajan
1 Make and Gprof COS Goals of Today’s Lecture Overview of two important programming tools  Make for compiling and linking multi-file programs.
Introduction to C Programming Overview of C Hello World program Unix environment C programming basics.
Performance Improvement
CSc 352 Performance Tuning Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
MCITP Guide to Microsoft Windows Server 2008 Server Administration (Exam #70-646) Chapter 14 Server and Network Monitoring.
Performance Measuring on Blue Horizon and Sun HPC Systems: Timing, Profiling, and Reading Assembly Language NPACI Parallel Computing Institute 2000 Sean.
1 Tuning PL/SQL procedures using DBMS_PROFILER 20-August 2009 Tim Gorman Evergreen Database Technologies, Inc. Northern California Oracle.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
1 1 Profiling & Optimization David Geldreich (DREAM)
1 CS 161 Introduction to Programming and Problem Solving Chapter 10 g++ Compiler Usage Herbert G. Mayer, PSU Status 10/21/2014.
Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to Embedded Systems Dr. Jerry Shiao, Silicon Valley University.
Chocolate Bar! luqili. Milestone 3 Speed 11% of final mark 7%: path quality and speed –Some cleverness required for full marks –Implement some A* techniques.
1 Unix Editors (ee, ed, ex, vi, vim) and Compilers (g77, gcc) Speaker: Li-Wen Chen Date:
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
GNU gcov (1/4) [from Wikipedia] gcov is a source code coverage analysis and statement- by-statement profiling tool. gcov generates exact counts of the.
Lecture 8. Profiling - for Performance Analysis - Prof. Taeweon Suh Computer Science Education Korea University COM503 Parallel Computer Architecture &
Unix Basics Chapter 4.
리눅스 : Lecture 5 UNIX 유틸리티 : text editor, compilation (make), …
GNU Compiler Collection (GCC) and GNU C compiler (gcc) tools used to compile programs in Linux.
Slides Prepared from the CI-Tutor Courses at NCSA By S. Masoud Sadjadi School of Computing and Information Sciences Florida.
Computer Engineering 1 nd Semester Dr. Rabie A. Ramadan 2.
Timing and Profiling ECE 454 Computer Systems Programming Topics: Measuring and Profiling Cristiana Amza.
1 Components of the Virtual Memory System  Arrows indicate what happens on a lw virtual address data physical address TLB page table memory cache disk.
Application Profiling Using gprof. What is profiling? Allows you to learn:  where your program is spending its time  what functions called what other.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 12/6/2006 Lecture 24 – Profilers.
Project 2: Initial Implementation Notes Tao Yang.
ENEE150 – 0102 ANDREW GOFFIN Testing and Debugging.
® IBM Software Group © 2006 IBM Corporation PurifyPlus on Linux / Unix Vinay Kumar H S.
Timing Programs and Performance Analysis Tools for Analysing and Optimising advanced Simulations.
Adv. UNIX: Profile/151 Advanced UNIX v Objectives –introduce profiling based on execution times and line counts Special Topics in Comp.
Power Profiling using Sim-Panalyzer Andria Dyess and Trey Brakefield CPE631 Spring 2005.
1 SEEM3460 Tutorial Compiling and Debugging C programs.
Performance Analysis & Code Profiling It’s 2:00AM -- do you know where your program counter is?
1 Announcements  Homework 4 out today  Dec 7 th is the last day you can turn in Lab 4 and HW4, so plan ahead.
Chapter 12 C Programming Tools Graham Glass and King Ables, UNIX for Programmers and Users, Third Edition, Pearson Prentice Hall, Original Notes.
Introduction to ECE 454 Computer Systems Programming Topics: Lecture topics and assignments Profiling rudiments Lab schedule and rationale Cristiana Amza.
Oct 2001ANSI C Under Unix (v1.0)1 UNIX C Programming under Unix written and presented by M.T.Stanhope.
Performance Improvement
Profiling Tools Introduction to Computer System, Fall (PPI, FDU) Vtune & GProfile.
1 Steps to use Flex Ravi Chotrani New York University Reviewed By Prof. Mohamed Zahran.
1 Performance Issues CIS*2450 Advanced Programming Concepts.
Basic Unix Commands & GCC Saurav Karmakar Spring 2007.
Copyright 2014 – Noah Mendelsohn Performance Analysis Tools Noah Mendelsohn Tufts University Web:
C P ROGRAMMING T OOLS. C OMPILING AND R UNNING S INGLE M ODULE P ROGRAM.
10/07/2011ecs40 fall Software Development & Object- Oriented Programming ecs40 Fall 2012: Software Development & Object- Oriented Programming #05:
Adding Links to a Page Index School Library Services Page.
July 10, 2016ISA's, Compilers, and Assembly1 CS232 roadmap In the first 3 quarters of the class, we have covered 1.Understanding the relationship between.
1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail.
Profiling with GNU GProf
Performance Analysis Tools
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha Fall 2015
Makefile Tutorial CIS5027 Prof: Dr. Shu-Ching Chen
Prof: Dr. Shu-Ching Chen TA: Yimin Yang
Python I/O.
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Compilers, Make and SubVersion
Tools.
  30 A 30 B 30 C 30 D 30 E 77 TOTALS ORIGINAL COUNT CURRENT COUNT
Operating Systems Lecture 3.
Tools.
Parallel Computing Explained Timing and Profiling
GNU gcov gcov is a test coverage program running with gcc.
Performance Tuning.
Makefiles, GDB, Valgrind
CSc 352 Performance Tuning
Presentation transcript:

GNU gprof Profiler Yu Kai Hong Department of Mathematics National Taiwan University July 19, 2008 GNU gprof 1/22

Two types of time profilers Built-in UNIX time profiler - Unix C shell - Others GNU gprof time profiler GNU gprof 2/22

Built-in UNIX time profiler The simplest one. Does not increase extra time cost. Does not provide subroutine relative graph. Does not have to recompile source code. GNU gprof 3/22

Built-in UNIX time profiler Unix C shell u : elapsed user time 0.016s : elapsed system time 0:15.61 : total elapsed time 95.5% : percent of total CPU usage 0+0k : shared/non-shared memory 0+0io : times for performing input/output home]$ time./test u 0.016s 0: % 0+0k 0+0io 0pf+0w GNU gprof 4/22

Built-in UNIX time profiler Others real 0m15.456s : total elapsed time user 0m14.990s : user elapsed time sys 0m0.015s : system elapsed time home]$ time./test real 0m15.456s user 0m14.990s sys 0m0.015s GNU gprof 5/22

GNU gprof time profiler Detail time statistics for each subroutine. Create relative graph for all subroutines. Analysis the program bottleneck. Increase about 30% extra time cost. GNU gprof 6/22

GNU gprof time profiler Recompile the original source code -pg : This option affects both compiling and linking. Add additional commands into source code when compiling code in order to trace all subroutines. Add essential initial settings and statistical processes when linking the objects. gcc –pg SourceCode –o ExecutableFile home]$ gcc –pg test2.c –o test2 GNU gprof 7/22

GNU gprof time profiler Convert produced profile data into text file - ListOfOptions can be omitted. - ExecuteFile can be omitted when the file name is a.out. - StatFiles can be omitted when the file name is gmon.out. gprof ListOfOptions ExecuteFile StatFiles > OutputFile home]$ gprof –b test2 gmon.out > output.txt GNU gprof 8/22

GNU gprof time profiler List of Options -b : omit the table or data illustration on OutputFile. -e(E) SRName : exclude the subroutine SRName from the table (and exclude its elapsed time). -f(F) SRName : only display the subroutine SRName on the table (and its elapsed time). GNU gprof 9/22

GNU gprof time profiler List of Options -s : combine more than one StatFile into single one with default file name gmon.sum. -Z : only display all subroutines table which are unused on the program. GNU gprof 10/22

GNU gprof time profiler Example Program subroutine relative graph GNU gprof 11/22

GNU gprof time profiler Example Program home]$ gcc –pg test.c –o test home]$./test home]$ gprof –b test gmon.out > output home]$ more output GNU gprof 2/22

GNU gprof time profiler Example Program Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls s/call s/call name C B C A B C D GNU gprof 13/22

GNU gprof time profiler Example Program % time : the percent of self seconds from total program elapsed time. cumulative seconds : the seconds cumulate from self seconds. self seconds : total elapsed time called by its parents, not including its children’s elapsed time. equal to (self s/call)*(calls) GNU gprof 14/22

GNU gprof time profiler Example Program calls : total number for each subroutine called by its parents. self s/call : elapsed time for each time called by its parents, not including its children’s elapsed time. total s/call : total elapsed time called by its parents, including its children’s elapsed time. name : subroutine name. GNU gprof 15/22

GNU gprof time profiler Example Program Call graph index %time self children called name [1] main[1] /1 A[2] /1 D[6] /1 main[1] [2] A[2] /1 B1[3] /2 B2[5] GNU gprof 16/22

GNU gprof time profiler Example Program /1 A[2] [3] B1[3] /1 C3[4] /1 C2[7] /1 C1[8] /1 B1[3] [4] C3[4] /2 A[2] /2 D[6] [5] B2[5] GNU gprof 17/22

GNU gprof time profiler Example Program /1 main[1] [6] D[6] /2 B2[5] /1 B1[3] [7] C2[7] /1 B1[3] [8] C1[8] GNU gprof 18/22

Example Program [ ] index value for each subroutine GNU gprof time profiler [2]A [8]C1 [6]D [3]B1 [7]C2 [5]B2 [4]C3 GNU gprof 19/22

Example Program See the second part. A on the left-most means the relation is viewed for A. B1 and B2 are below of A means A is the parent of B1 and B2 (A calls B1 and B2), main is above of A means A is the child of main (A called by main). GNU gprof time profiler name main[1] A[2] D[6] main[1] A[2] B1[3] B2[5] GNU gprof 20/22

Example Program See the second part. 1/2 means subroutine B2 is called by its parents total two times and A calls it only one time. 1 means subroutine A have only one parent. GNU gprof time profiler called name main[1] 1/1 A[2] 1/1 D[6] /1 main[1] 1 A[2] 1/1 B1[3] 1/2 B2[5] GNU gprof 21/22

Example Program See the second part It is viewed for subroutine A. The elapsed time of A’s children is seconds and B1’s children is seconds. Especially, B2’s children is 0 second since B2 doesn’t have any child. GNU gprof time profiler children name main[1] A[2] 4.07 D[6] main[1] A[2] B1[3] 0.00 B2[5] GNU gprof 22/22