
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Profile C++ Code Running in Linux
There are many great profiling tools for profiling C++ programs on Linux. The most widely used tool is Valgrind. It is a programming tool for memory debugging, memory leak detection, and profiling. You 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 hello.cpp hello Now use valgrind to profile it: $ valgrind --tool=callgrind ./hello
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 hello hello.cpp -g -pg
Advertisements