#include <stdio.h>
#include <stdlib.h>
#include <time.h>

long long now_ns() {
    struct timespec ts;
    clock_gettime(CLOCK_MONOTONIC, &ts);
    return ts.tv_sec*1000000000uL + ts.tv_nsec;
}

int main(int argc, char *argv[]) {
    printf("Tick %lld\n", now_ns()-now_ns());
    printf("Tick %lld\n", now_ns()-now_ns());
    printf("Tick %lld\n", now_ns()-now_ns());

    char *array = malloc(0x1000000);

    long long t0 = now_ns();
    array[0] = 'x';
    long long t1 = now_ns();
    array[0x987654] = 'y';
    long long t2 = now_ns();
    printf("Access times: %lld and %lld\n", t1-t0, t2-t1);

    long long t3 = now_ns();
    array[1] = 'x';
    long long t4 = now_ns();
    array[0x987655] = 'y';
    long long t5 = now_ns();
    printf("Access times: %lld and %lld\n", t4-t3, t5-t4);

    return 0;
}