Created
January 4, 2017 07:44
-
-
Save dreamflyforever/b976bfffb8e3c12db2d4a77df620e4f3 to your computer and use it in GitHub Desktop.
From chrome://newtab/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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