Blame src/stdio/bench.c

nsz dc655a
#include <stdio.h>
nsz dc655a
#include <stdlib.h>
nsz dc655a
#include <string.h>
nsz dc655a
#include "test.h"
nsz dc655a
nsz 086c6a
void bench_stdio_getc_unlocked(int N) {
nsz 086c6a
	FILE *f = tmpfile();
nsz 086c6a
	size_t i;
nsz 086c6a
	size_t cs = 0;
nsz 086c6a
nsz 086c6a
	for (i=0; i
nsz 086c6a
		putc('x', f);
nsz 086c6a
	fseeko(f, 0, SEEK_SET);
nsz 086c6a
	reset_timer();
nsz 086c6a
	for (i=0; i
nsz 086c6a
		cs += getc_unlocked(f);
nsz 086c6a
	fclose(f);
nsz 086c6a
	if (cs != (size_t)N*'x')
nsz 086c6a
		abort();
nsz 086c6a
}
nsz 086c6a
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
}