RED HAT
RED HAT
DIIDevHeads IoT Integration Server
Created by Marvee Amasi on 7/4/2024 in #middleware-and-os
Optimizing a bubble sort implementation in C for an x86-64 architecture
Compile your code with profiling enabled using
Copy code
gcc -pg -O3 -o sort sort.c
./sort 1000000
gprof sort gmon.out > analysis.txt
Copy code
gcc -pg -O3 -o sort sort.c
./sort 1000000
gprof sort gmon.out > analysis.txt
For perf, use
perf record -g ./sort 1000000
perf record -g ./sort 1000000
Generate a report to get full detail of where time is being spent on your program
perf report
perf report
13 replies