5 Performance Analysis setup
Mateo Rodrigo Argudo Arrieta edited this page 2021-09-28 16:50:16 +02:00

Performance with Vtune:

Use Vtunes for Hotspot profiling:

  1. With GUI:

    From terminal open with vtune-gui and open your project for analysis. At first this will generate a flat profile where you can choose the hotspot options.

  2. In Terminal:

    from terminal use the command:

     vtunne -collect hotspots ./<source-excecutable>
    

Performance with Gprof:

Use Gprof for Flat and Function Call Graph profiling:

SETUP

    Compile and build the project in terminal with this line of code before make:
    

        cmake -DCMAKE_CXX_FLAGS=-pg -DCMAKE_EXE_LINKER_FLAGS=-pg -DCMAKE_SHARED_LINKER_FLAGS=-pg <SOURCE_DIR>
        

        The directory should be where you have the Cmake file for the project.

ANALYSIS

    After running one of the excecutables a gmon.out file is generated:

        Go to the directory where gmon.out file is located and analyse with:
        

            gprof -p ./<excecutable>   >[outputfilename with directory] 
            

        for a flat profiling of times.

        And for a call graph:
        

            gprof -q ./<excecutable>   >[outputfilename with directory]
            
        For a table with the top 10 lines of code for the script functions:


            gprof -A -I -t ./<excecutable>   >[outputfilename with directory]    
       
       
       -A is for source code listing and -I for gprof to find the excecutable.

Visualisation:

    The output files can be opened with any text editor.

Performance with Valgrind:

Use Gprof for Cache and Call Graph analysis:

SETUP

    Build with RelWithDebInfo option so that SIGILL does not appear (illegal opcode)

ANALYSIS

    Go to the build you want to analyse with cd <source-of-build>


    Cache Analysis:
    

        valgrind --tool=cachegrind ./bin/<excecutable>
        

        this will generate a cachegrind.out.<id> file in the directory where you analysed, which you can annotate using.
        

    Cache Analysis Presentation:
    

        cg_annotate cachegrind.out.<id>
        

    Function Call Analysis:
    

        valgrind --tool=callgrind ./bin/<excecutable>
        

        this will generate a cachegrind.out.<id> file in the directory where you analysed, which you can annotate using.

    
        The Assembly code is visualized using two more options running:
        
        
        valgrind --tool=callgrind --dump-instr=yes --collect-jumps=yes ./bin/<excecutable>
        
       

    Call Analysis Presentation:
    

        callgrind_annotate callgrind.out.<id>

GUI Presentation:

    All the .out.<id> files can be presented through KCachegrind. Open it from the GUI. Errors may appear if you want to open them directly from terminal.