UC3M

Telematic/Audiovisual Syst./Communication Syst. Engineering

Systems Architecture

September 2017 - January 2018

14.4.  Optimizing code

The command interpreter BASH allows to measure the execution time of any command by simply adding the time command at the beginning of the line. The time is divided into three categories: total time, user time and system time. The measurements are approximate, so the sum of the last two does not necessarily amount to the first one. Execute the program with the command

$ time ./main_en

and write down the result.

One of the most powerful functionalities of the compiler is optimizing code. There are numerous techniques to analyze and transform the code initially generated by the compiler to obtain better performance in execution time or memory use. The compiler applies these techniques when given the -O option. Compile your program again with this option and execute it with the time as prefix. Compare the to execution times. Do you think the compiler is effective at optimizing the code?