- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I 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
- How can I profile C++ code running on Linux?
- How can I stop running a MySQL query?
- How can I stop a running MySQL query?
- Executing C# code in Linux
- How can I create directory tree using C++ in Linux?
- How to write a running C code without main()?
- How to list running screen sessions on Linux?
- How to find and kill running processes in linux
- Running GUI applications on docker in linux
- How I can show progress of long running PYTHON CGI script?
- How I can install unidecode python module on Linux?
- How can I run a Linux command using Python CGI script?
- How can I write unit tests against code that uses Matplotlib?
- How to show historical and statistical running time of linux systems