Check the execution time of the program in C language

htt‮/:sp‬/www.lautturi.com
Check the execution time of the program in C language
// get the execution time of the program
#include <time.h>
#include <sys/time.h>
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char **argv)
{

  struct timeval start, end;

  gettimeofday(&start, NULL); // start time

  for (int i = 0; i < 1000000; i++)
  {
    }

  gettimeofday(&end, NULL); // end time

  printf("%ld\n", ((end.tv_sec * 1000000 + end.tv_usec)
		  - (start.tv_sec * 1000000 + start.tv_usec)));

  return 0;
}
Created Time:2017-08-28 16:01:18  Author:lautturi