Skip to content

Instantly share code, notes, and snippets.

@xk
Created July 6, 2012 19:03
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 xk/3062129 to your computer and use it in GitHub Desktop.
Save xk/3062129 to your computer and use it in GitHub Desktop.
js_vs_c.c
//2012-06-28 js_vs_c.c
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
long long DateNow () {
struct timeval time;
gettimeofday(&time, NULL);
return (long long) ((time.tv_sec* 1000000) + time.tv_usec);
}
int main (int argc, char** argv) {
long long t, now;
long c;
c= 0;
t= DateNow()+1e6;
while (c++, (now= DateNow()) < t) ;
printf("%ld\n", c);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment