projects
/
libc-test
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
95f9b902d6a35356251f236236cc92af5e444057
[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_putcgetc(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
for (i=0; i<N; i++)
15
cs += getc(f);
16
fclose(f);
17
if (cs != (size_t)N*'x')
18
abort();
19
}
20
21
void bench_stdio_putcgetc_unlocked(int N) {
22
FILE *f = tmpfile();
23
size_t i;
24
size_t cs = 0;
25
26
for (i=0; i<N; i++)
27
putc_unlocked('x', f);
28
fseeko(f, 0, SEEK_SET);
29
for (i=0; i<N; i++)
30
cs += getc_unlocked(f);
31
fclose(f);
32
if (cs != (size_t)N*'x')
33
abort();
34
}