Blame src/stdio/bench.c

nsz dc655a
#define _POSIX_C_SOURCE 200809L
nsz dc655a
#include <stdio.h>
nsz dc655a
#include <stdlib.h>
nsz dc655a
#include <string.h>
nsz dc655a
#include "test.h"
nsz dc655a
nsz 7d87d3
void bench_stdio_putcgetc(int N) {
nsz dc655a
	FILE *f = tmpfile();
nsz dc655a
	size_t i;
nsz dc655a
	size_t cs = 0;
nsz dc655a
nsz dc655a
	for (i=0; i
nsz dc655a
		putc('x', f);
nsz dc655a
	fseeko(f, 0, SEEK_SET);
nsz dc655a
	for (i=0; i
nsz dc655a
		cs += getc(f);
nsz dc655a
	fclose(f);
nsz dc655a
	if (cs != (size_t)N*'x')
nsz dc655a
		abort();
nsz dc655a
}
nsz dc655a
nsz 7d87d3
void bench_stdio_putcgetc_unlocked(int N) {
nsz dc655a
	FILE *f = tmpfile();
nsz dc655a
	size_t i;
nsz dc655a
	size_t cs = 0;
nsz dc655a
nsz dc655a
	for (i=0; i
nsz dc655a
		putc_unlocked('x', f);
nsz dc655a
	fseeko(f, 0, SEEK_SET);
nsz dc655a
	for (i=0; i
nsz dc655a
		cs += getc_unlocked(f);
nsz dc655a
	fclose(f);
nsz dc655a
	if (cs != (size_t)N*'x')
nsz dc655a
		abort();
nsz dc655a
}