/* Collection of code snippets by Arne Vajhøj */
/* (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) */
#include <stdio.h>

#include "high_res_timer.h"

static void test(const char *fnm)
{
    FILE *fp;
    char line[1000];
    TIMECOUNT_T t1, t2;
    int n;
    t1 = GET_TIMECOUNT;
    fp = fopen(fnm, "r");
    n = 0;
    while(fgets(line, sizeof(line), fp))
    {
        n++;
    }
    printf("%d lines\n", n);
    fclose(fp);
    t2 = GET_TIMECOUNT;
    printf("Read one line at a time : %d ms\n", (int)((t2 - t1) * 1000 / UNITS_PER_SECOND));
}

int main(int argc, char *argv[])
{
    int i;
    for(i = 0; i < 3; i++)
    {
        test(argv[1]);
    }
    return 0;
}
