コマンドを使って実行する方法もあるけれど、
__おおよその実行時間__を出すコード。
あくまで大体の時間なので、目安として使う時だけ。
# include <stdio.h>
# include <time.h>
//時間計測
clock_t cpu_time_start;
clock_t cpu_time_end;
double sec_start;
double sec_end;
double result_time;
int main(void)
{
//計測開始
cpu_time_start = clock();
sec_start = (double)cpu_time_start/CLOCKS_PER_SEC;
printf("開始時間 : %f\n\n",sec_start);
// ここに処理を書く
//計測終了
cpu_time_end = clock();
sec_end = (double)cpu_time_end/CLOCKS_PER_SEC;
printf("\n終了時間 : %f\n",sec_end);
//処理時間
result_time = sec_end - sec_start;
printf("処理時間 : %f\n",result_time);
return (0);
}
2020/04/19 追記
関数をひとつずつ調べない場合はこっちの書き方の方でOK。
# include <stdio.h>
# include <time.h>
int main(void)
{
// ここに処理を書く
printf("%f秒\n", ((double)clock()) / CLOCKS_PER_SEC);
return 0;
}