Skip to content

Instantly share code, notes, and snippets.

@silv3rm00n
Created March 9, 2012 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silv3rm00n/2005431 to your computer and use it in GitHub Desktop.
Save silv3rm00n/2005431 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <sys/time.h>
int main()
{
int i;
double before_ms , after_ms;
struct timeval before , after;
gettimeofday(&before , NULL);
before_ms = (double)before.tv_sec*1000 + (double)before.tv_usec/1000;
printf("%d , %d , and in ms : %lf \n" , before.tv_sec , before.tv_usec , before_ms);
//Task
for (i=1;i<= 10;++i)
{
printf("%d %d %d \n",i, i*i, i*i*i);
}
gettimeofday(&after , NULL);
after_ms = (double)after.tv_sec*1000 + (double)after.tv_usec/1000;
printf("%d , %d , and in ms : %lf \n" , after.tv_sec , after.tv_usec , after_ms);
printf("Elapsed (in ms) %lf" , (double)after_ms - before_ms);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment