0% found this document useful (0 votes)
51 views1 page

How To Use Profiling Tools New

Valgrind is a memory profiling tool that can detect memory errors in C and C++ programs. Its Memcheck tool checks for memory leaks and errors. Massif is a heap profiler that measures memory usage. To use Massif, run your program with valgrind and the massif tool, then use ms_print to view the output. Gprof is a time profiling tool. To use it, compile with -pg, run your program, then use gprof on the executable to view profiling information about execution time.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views1 page

How To Use Profiling Tools New

Valgrind is a memory profiling tool that can detect memory errors in C and C++ programs. Its Memcheck tool checks for memory leaks and errors. Massif is a heap profiler that measures memory usage. To use Massif, run your program with valgrind and the massif tool, then use ms_print to view the output. Gprof is a time profiling tool. To use it, compile with -pg, run your program, then use gprof on the executable to view profiling information about execution time.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

How to use Profiling tools

A.Valgrind - Memory profiling tool


The Valgrind tool suite provides a number of debugging and profiling tools
that help you make your programs faster and more correct. The most popular of these
tools is called Memcheck. It can detect many memory-related errors that are common
in C and C++ programs and that can lead to crashes and unpredictable behaviour.

Memcheck tool:
1.Preparing your program -
Compile your program with -g to include debugging information so that
Memcheck's error messages include exact line numbers.

2.Running your program under Memcheck -


If you normally run your program like this:
myprog arg1 arg2

Use this command line:


valgrind --leak-check=yes myprog arg1 arg2

Massif tool : a heap profiler


Massif is a heap profiler. It measures how much heap memory your program
uses.

1.To gather heap profiling information about the program prog, type:
valgrind --tool=massif prog

2.Running ms_print -
To see the information gathered by Massif in an easy-to-read form, use
ms_print.
ms_print massif.out.12345

B.gprof - Time profiling tool


To determine which parts of a program are taking most of the execution time

1.Compile and link with the -pg option.

2. Run your program normally; that is, pretend you didn't do anything to it and do
what you would normally do (checking difficult, slow, or fast cases, of course).

3.Type gprof exec > out where exec is replaced by your executable's name and out by
some meaningful name for the profiling information.

4.Look over the output and learn what it means.

You might also like