first commit!
This commit is contained in:
22
register.c
Normal file
22
register.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
int main() {
|
||||
struct timespec t0, t1;
|
||||
long int i = 0;
|
||||
register long int x = 0;
|
||||
|
||||
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t0);
|
||||
for (; i < 1000; ++i)
|
||||
printf("%ld ", i + 1);
|
||||
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t1);
|
||||
printf("\n%ldns took usual var", (t1.tv_sec - t0.tv_sec) * (long)1e9 + (t1.tv_nsec - t0.tv_nsec));
|
||||
printf("\n\n");
|
||||
|
||||
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t0);
|
||||
for (; x < 1000; ++x)
|
||||
printf("%ld ", x + 1);
|
||||
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t1);
|
||||
|
||||
printf("\n%ldns took register var", (t1.tv_sec - t0.tv_sec) * (long)1e9 + (t1.tv_nsec - t0.tv_nsec));
|
||||
}
|
Reference in New Issue
Block a user