Skip to content

Instantly share code, notes, and snippets.

@dreamflyforever
Created January 4, 2017 07:44
Show Gist options
  • Save dreamflyforever/b976bfffb8e3c12db2d4a77df620e4f3 to your computer and use it in GitHub Desktop.
Save dreamflyforever/b976bfffb8e3c12db2d4a77df620e4f3 to your computer and use it in GitHub Desktop.
From chrome://newtab/
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#define MILLION 1000000
long clock_get()
{
long ret;
struct timespec t;
clock_gettime(CLOCK_MONOTONIC, &t);
ret = t.tv_sec * MILLION + t.tv_nsec/1000;
return ret;
}
long calcu(long start, long end)
{
long r = (end - start)/1000;
return r;
}
int main(void)
{
long int loop = 1000;
long start;
long end;
long timedif;
start = clock_get();
while (--loop){
system("cd");
}
end = clock_get();
timedif = calcu(start, end);
fprintf(stdout, "it took %ld milliseconds\n", timedif);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment