#include <stdio.h>
#include <string.h>
#include <sys/time.h>

int test() {
    char buf[128];
    strcpy(buf, "1234567890");
    return strncmp(buf, "1234", 4);
}

unsigned long time_diff(struct timeval *start, struct timeval *end) {
    unsigned long msec;

    msec = (end->tv_sec * 1000) + (end->tv_usec / 1000);
    msec -= (start->tv_sec * 1000) + (start->tv_usec / 1000);
    return msec;
}

int main(void) {
    int i = 0;
    unsigned long max = 1000 * 1000 * 1000;
    struct timeval start, end;
    unsigned long msec;

    printf(" trying %lu executions\n", max);
    gettimeofday(&start, NULL);

    for (i = 0; i < max; i++) {
        test();
    }

    gettimeofday(&end, NULL);
    msec = time_diff(&start, &end);

    printf(" took %lu miliseconds\n", msec);

    return 0;
}

