wstęp Opis Profilowanie pod Linuxem. gcc + gprof by mateusz midor Krytyczna analiza Alternatywy dla gprof
Etapy skompiluj program w celu profilowania, tzn. z opcjami -pg -g Debugging and profiling your C/C++ programs using Free Software by Xenofon Papadopoulos uruchom program (w celu utworzenia danych dla profilera)GNU gprof uruchom profiler analizuj profil (wynik profilera)GPROF Tutorial – How to use Linux GNU GCC Profiling Tool by Himanshu Arora on August 10, 2012 analiza tekstu analiza graficzna : gprof2dotgprof2dot by José Fonseca
Analiza
Utworzenie pliku do analizy graficznej:scicomp stackexchange question: profiling-optimized-c-code-using-gprof
chmod 0700 gprof2dot.py
gprof ./a.out| gprof2dot.py | dot -T pdf > profile.pdf gprof ./a.out| gprof2dot.py | dot -T png > profile.png
Przykład Przykład profile-c-program-linux gcc -pg -Wall myfile.c # run myfile ./a.out # generate the profile gprof ./a.out
lub do pliku tekstowego prof.txt (nazwa przykładowa):
gprof ./a.out > prof.txt
Przykładowy wynik (dla programu z commonsProgram z commons) zawiera 2 części: płaski profil graf wywołań
Flat profile:
Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls us/call us/call name 37.89 7.07 7.07 4004001 1.77 1.77 ComputeColor 34.89 13.59 6.51 200000162 0.03 0.03 iDrawLine 16.03 16.58 2.99 200000241 0.01 0.05 dDrawLine.constprop.0 10.72 18.58 2.00 ComputeRays 0.32 18.64 0.06 ColourNewTrap 0.16 18.67 0.03 ComputeBoundariesIn 0.05 18.68 0.01 CopyRaysTo 0.00 18.68 0.00 2 0.00 0.00 SaveFiles4ManualDebug 0.00 18.68 0.00 1 0.00 0.00 FillGapsInRaysArray 0.00 18.68 0.00 1 0.00 0.00 GiveC
% the percentage of the total running time of the time program used by this function.
cumulative a running sum of the number of seconds accounted seconds for by this function and those listed above it.
self the number of seconds accounted for by this seconds function alone. This is the major sort for this listing.
calls the number of times this function was invoked, if this function is profiled, else blank.
self the average number of milliseconds spent in this ms/call function per call, if this function is profiled, else blank.
total the average number of milliseconds spent in this ms/call function and its descendents per call, if this function is profiled, else blank.
name the name of the function. This is the minor sort for this listing. The index shows the location of the function in the gprof listing. If the index is in parenthesis it shows where it would appear in the gprof listing if it were to be printed.
Call graph (explanation follows)
granularity: each sample hit covers 2 byte(s) for 0.05% of 18.68 seconds
index % time self children called name
61.6 2.00 9.51 ComputeRays 2.99 6.51 200000241/200000241 dDrawLine.constprop.0 0.00 0.00 2/2 SaveFiles4ManualDebug 0.00 0.00 1/1 FillGapsInRaysArray
2.99 6.51 200000241/200000241 ComputeRays 50.9 2.99 6.51 200000241 dDrawLine.constprop.0 6.51 0.00 200000162/200000162 iDrawLine
7.07 0.00 4004001/4004001 ComputeFatouComponents 37.9 7.07 0.00 4004001 ComputeColor
37.9 0.00 7.07 ComputeFatouComponents 7.07 0.00 4004001/4004001 ComputeColor
6.51 0.00 200000162/200000162 dDrawLine.constprop.0 34.9 6.51 0.00 200000162 iDrawLine
0.3 0.06 0.00 ColourNewTrap
0.2 0.03 0.00 ComputeBoundariesIn
0.1 0.01 0.00 CopyRaysTo
0.00 0.00 2/2 ComputeRays 0.0 0.00 0.00 2 SaveFiles4ManualDebug
0.00 0.00 1/1 ComputeRays 0.0 0.00 0.00 1 FillGapsInRaysArray
0.00 0.00 1/1 setup 0.0 0.00 0.00 1 GiveC
This table describes the call tree of the program, and was sorted by the total amount of time spent in each function and its children.
Odnośniki