
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
How can I profile C++ code running on Linux?
In Linux platform there are many great profiling tools for profiling C++ programs. Valgrind is one of them. It is widely used. It is a programming tool for memory debugging, memory leak detection, and profiling. We can use Valgrind by passing the binary to it and setting the tool to callgrind. First generate the binary by compiling the program
$ g++ -o abc.cpp abc
Now use valgrind to profile it
$ valgrind --tool=callgrind ./abc
This will generate a file called callgrind.out.x. You can read this file using a tool called kcachegrind.
If you're using gcc, you can use the inbuilt profiling tool, gprof. You can use it while compiling the file as follows
$ g++ -o abc abc.cpp -g -pg
- Related Articles
- How can I profile C++ code running in Linux?
- How to list running screen sessions on Linux?
- How I can install unidecode python module on Linux?
- Running GUI applications on docker in linux
- Running Multiple Commands in the Background on Linux
- How can I stop a running MySQL query?
- How can I stop running a MySQL query?
- 25 Big Companies and Devices Running on GNU/Linux
- Redirecting the Output of an Already Running Process on Linux
- How to increase the scrollback buffer in a running screen session on Linux?
- Read the Source Code of Shell Commands on Linux
- How can I add debugging code to my JavaScript?
- How to write a running C code without main()?
- How can I use wstring(s) in Linux APIs
- Ensure Only One Instance of a Bash Script Is Running on Linux

Advertisements