strtoul test fix, infrastructure changes
[libc-test] / src / stdio / bench.c
index 625a217..0e87845 100644 (file)
@@ -1,10 +1,25 @@
-#define _POSIX_C_SOURCE 200809L
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include "test.h"
 
-void bench_stdio_putcgetc() {
+void bench_stdio_getc_unlocked(int N) {
+       FILE *f = tmpfile();
+       size_t i;
+       size_t cs = 0;
+
+       for (i=0; i<N; i++)
+               putc('x', f);
+       fseeko(f, 0, SEEK_SET);
+       reset_timer();
+       for (i=0; i<N; i++)
+               cs += getc_unlocked(f);
+       fclose(f);
+       if (cs != (size_t)N*'x')
+               abort();
+}
+
+void bench_stdio_putcgetc(int N) {
        FILE *f = tmpfile();
        size_t i;
        size_t cs = 0;
@@ -19,7 +34,7 @@ void bench_stdio_putcgetc() {
                abort();
 }
 
-void bench_stdio_putcgetc_unlocked() {
+void bench_stdio_putcgetc_unlocked(int N) {
        FILE *f = tmpfile();
        size_t i;
        size_t cs = 0;