strtoul test fix, infrastructure changes
[libc-test] / src / stdio / bench.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "test.h"
5
6 void bench_stdio_getc_unlocked(int N) {
7         FILE *f = tmpfile();
8         size_t i;
9         size_t cs = 0;
10
11         for (i=0; i<N; i++)
12                 putc('x', f);
13         fseeko(f, 0, SEEK_SET);
14         reset_timer();
15         for (i=0; i<N; i++)
16                 cs += getc_unlocked(f);
17         fclose(f);
18         if (cs != (size_t)N*'x')
19                 abort();
20 }
21
22 void bench_stdio_putcgetc(int N) {
23         FILE *f = tmpfile();
24         size_t i;
25         size_t cs = 0;
26
27         for (i=0; i<N; i++)
28                 putc('x', f);
29         fseeko(f, 0, SEEK_SET);
30         for (i=0; i<N; i++)
31                 cs += getc(f);
32         fclose(f);
33         if (cs != (size_t)N*'x')
34                 abort();
35 }
36
37 void bench_stdio_putcgetc_unlocked(int N) {
38         FILE *f = tmpfile();
39         size_t i;
40         size_t cs = 0;
41
42         for (i=0; i<N; i++)
43                 putc_unlocked('x', f);
44         fseeko(f, 0, SEEK_SET);
45         for (i=0; i<N; i++)
46                 cs += getc_unlocked(f);
47         fclose(f);
48         if (cs != (size_t)N*'x')
49                 abort();
50 }