profile time bash script

#!/bin/bash
gcc -Wall -o output program.c
time ./output

Explanation:

  • #!/bin/bash: This shebang line at the beginning of the script tells the system to use the Bash shell to execute the script.
  • gcc -Wall -o output program.c: This line compiles the C program "program.c" using the "gcc" compiler with the "-Wall" flag to enable all warnings and the "-o output" flag to specify the name of the output executable as "output".
  • time ./output: This line runs the compiled executable "output" and uses the "time" command to measure the time taken for the program to execute. The "time" command provides information about the resources used by the command, including the time it took to run.

This script first compiles a C program using the "gcc" compiler with certain flags, and then measures the execution time of the compiled program using the "time" command.