Using GPROF
This command will generate a test file:
gcc -lm -pg sobel.c ./a.out gprof a.out > test
test file:
% cumulative self self total 100.27 0.04 0.04 1 40.11 40.11 sobel_filtering 0.00 0.04 0.00 1 0.00 0.00 load_image_data 0.00 0.04 0.00 1 0.00 0.00 save_image_data