Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.



Qt Creator gprof example 1: profiling a simple console application in Qt Creator, using Build Settings is a
gprof example that shows how to profile a simple console application in Qt Creator,
using the Build Settings.
Here follows a step-by-step guide to use gprof to do the profiling of a simple Qt Creator project:
- Go to 'Projects -> Build Settings' and add a custom Build step. Fill in the information as in the screenshot below
- View screenshot
- View your project folder. There will be few files
- View screenshot
- Run the program. The executable 'profile_main' has been created in your project folder
- View screenshot
- Run 'profile_main' and the file 'gmon.out' is created
- View screenshot
- Start a Terminal, go to the project folder and use the command 'gprof profile_main > profile.txt'
- View screenshot
- The file 'profile.txt' will be created
- View screenshot
- The file 'profile.txt' will contain the profiling information
Profiling results
Here I show the results comparing the five functions, copied from the results file:
Flat profile:
% cumulative self self total
time seconds seconds calls ms/call ms/call name
13.59 1.54 0.28 1 280.00 700.00 void BubbleSort<int>(std::vector<int, std::allocator<int> >&)
12.14 1.79 0.25 1 250.00 670.00 void InsertionSort<int>(std::vector<int, std::allocator<int> >&)
11.65 2.03 0.24 1 240.00 660.00 void SelectionSort<int>(std::vector<int, std::allocator<int> >&)
0.00 2.06 0.00 1 0.00 24.98 void SortVector<int>(std::vector<int, std::allocator<int> >&)
0.00 2.06 0.00 1 0.00 5.02 CreateShuffledVector(unsigned int)
|
Conclusion: as expected, SortVector (a QuickSort) is by far the quickest sorting algorithm.
Technical facts
Operating system(s) or programming environment(s)
IDE(s):
Project type:
C++ standard:
Compiler(s):
Libraries used:
STL: GNU ISO C++ Library, version 4.9.2
Qt project file: ./CppGprofQtCreatorExample1/CppGprofExample1.pro
./CppGprofQtCreatorExample1/main.cpp
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.

This page has been created by the tool CodeToHtml