blob: 37616e42395792f1200fa8ccf393f934066ed21a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#include <assert.h>
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "csv.h"
static int
test(FILE *f)
{
int line = 0;
csv_t csv = { 0 };
while ( csv_read(&csv, f) ) {
++line;
}
return line;
}
int
main(int argc, char *argv[])
{
if ( argc != 2 ) {
fprintf(stderr, "usage: %s testfile\n", argv[0]);
return EXIT_FAILURE;
}
FILE *in = fopen(argv[1], "r");
if ( in == NULL ) {
fprintf(stderr, "failed to open testfile...\n");
return EXIT_FAILURE;
}
clock_t start = clock();
int lines = test(in);
clock_t end = clock();
fclose(in);
printf("%d lines processed, duration: %.3lf sec\n", lines, ((double) (end - start)) / CLOCKS_PER_SEC);
return EXIT_SUCCESS;
}
|